3
0

u-box.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. @import "../../libs/css/components.scss";
  53. .u-box {
  54. /* #ifndef APP-NVUE */
  55. /* #endif */
  56. @include flex();
  57. flex: 1;
  58. &__left {
  59. @include flex();
  60. justify-content: center;
  61. align-items: center;
  62. flex: 1;
  63. }
  64. &__gap {
  65. @include flex();
  66. flex-direction: column;
  67. }
  68. &__right {
  69. @include flex();
  70. flex-direction: column;
  71. flex: 1;
  72. }
  73. &__right-top {
  74. @include flex();
  75. flex: 1;
  76. justify-content: center;
  77. align-items: center;
  78. }
  79. &__right-bottom {
  80. @include flex();
  81. flex: 1;
  82. justify-content: center;
  83. align-items: center;
  84. }
  85. }
  86. </style>