u-box.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="u-box" :style="[{height: height}, addStyle(customStyle)]">
  3. <view class="u-box__left" :style="{borderRadius: borderRadius, backgroundColor: bgColors[0]}">
  4. <slot name="left">左</slot>
  5. </view>
  6. <view class="u-box__gap" :style="{width: gap, height: height}"></view>
  7. <view class="u-box__right">
  8. <view class="u-box__right-top" :style="{borderRadius: borderRadius, backgroundColor: bgColors[1]}">
  9. <slot name="rightTop">右上</slot>
  10. </view>
  11. <view class="u-box__right-gap" :style="{height: gap}"></view>
  12. <view class="u-box__right-bottom" :style="{borderRadius: borderRadius, backgroundColor: bgColors[2]}">
  13. <slot name="rightBottom">右下</slot>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { propsBox } from './props';
  20. import { mpMixin } from '../../libs/mixin/mpMixin';
  21. import { mixin } from '../../libs/mixin/mixin';
  22. import { addStyle } from '../../libs/function/index';
  23. import test from '../../libs/function/test';
  24. /**
  25. * box 盒子
  26. * @description box盒子一般为左边一个盒子,右侧两个等高的半盒组成,常用于App首页座位重点突出。
  27. * @tutorial https://uview-plus.jiangruyi.com/components/box.html
  28. * @property {Array} bgColors 背景色
  29. * @property {String} height 高度
  30. * @property {String} borderRadius 圆角
  31. * @property {Object} customStyle 定义需要用到的外部样式
  32. *
  33. * @event {Function} click 点击cell列表时触发
  34. * @example <up-box colors=['blue', 'red', 'yellow'] height="200px"></up-box>
  35. */
  36. export default {
  37. name: 'up-box',
  38. data() {
  39. return {
  40. }
  41. },
  42. mixins: [mpMixin, mixin, propsBox],
  43. computed: {
  44. },
  45. emits: [],
  46. methods: {
  47. addStyle,
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .u-box {
  53. /* #ifndef APP-NVUE */
  54. /* #endif */
  55. @include flex();
  56. flex: 1;
  57. &__left {
  58. @include flex();
  59. justify-content: center;
  60. align-items: center;
  61. flex: 1;
  62. }
  63. &__gap {
  64. @include flex();
  65. flex-direction: column;
  66. }
  67. &__right {
  68. @include flex();
  69. flex-direction: column;
  70. flex: 1;
  71. }
  72. &__right-top {
  73. @include flex();
  74. flex: 1;
  75. justify-content: center;
  76. align-items: center;
  77. }
  78. &__right-bottom {
  79. @include flex();
  80. flex: 1;
  81. justify-content: center;
  82. align-items: center;
  83. }
  84. }
  85. </style>