index.vue 4.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <uni-shadow-root class="vant-dist-grid-item-index"><view :class="'custom-class '+(utils.bem('grid-item', { square }))" :style="computed.wrapperStyle({ square, gutter, columnNum, index })" @click="onClick">
  3. <view :class="'content-class '+(utils.bem('grid-item__content', [direction, { center, square, reverse, clickable, surround: border && gutter }]))+' '+(border ? 'van-hairline--surround' : '')" :style="computed.contentStyle({ square, gutter })">
  4. <block v-if="useSlot">
  5. <slot></slot>
  6. </block>
  7. <block v-else>
  8. <view class="van-grid-item__icon icon-class">
  9. <van-icon v-if="icon" :name="icon" :color="iconColor" :class-prefix="iconPrefix" :dot="dot" :info="badge || info" :size="iconSize"></van-icon>
  10. <slot v-else name="icon"></slot>
  11. </view>
  12. <view class="van-grid-item__text text-class">
  13. <text v-if="text">{{ text }}</text>
  14. <slot v-else name="text"></slot>
  15. </view>
  16. </block>
  17. </view>
  18. </view></uni-shadow-root>
  19. </template>
  20. <wxs src="../wxs/utils.wxs" module="utils"></wxs><wxs src="./index.wxs" module="computed"></wxs>
  21. <script>
  22. import VanIcon from '../icon/index.vue'
  23. global['__wxVueOptions'] = {components:{'van-icon': VanIcon}}
  24. global['__wxRoute'] = 'vant/dist/grid-item/index'
  25. import { VantComponent } from '../common/component';
  26. import { useParent } from '../common/relation';
  27. import { link } from '../mixins/link';
  28. VantComponent({
  29. relation: useParent('grid'),
  30. classes: ['content-class', 'icon-class', 'text-class'],
  31. mixins: [link],
  32. props: {
  33. icon: String,
  34. iconColor: String,
  35. iconPrefix: {
  36. type: String,
  37. value: 'van-icon',
  38. },
  39. dot: Boolean,
  40. info: null,
  41. badge: null,
  42. text: String,
  43. useSlot: Boolean,
  44. },
  45. data: {
  46. viewStyle: '',
  47. },
  48. mounted() {
  49. this.updateStyle();
  50. },
  51. methods: {
  52. updateStyle() {
  53. if (!this.parent) {
  54. return;
  55. }
  56. const { data, children } = this.parent;
  57. const { columnNum, border, square, gutter, clickable, center, direction, reverse, iconSize, } = data;
  58. this.setData({
  59. center,
  60. border,
  61. square,
  62. gutter,
  63. clickable,
  64. direction,
  65. reverse,
  66. iconSize,
  67. index: children.indexOf(this),
  68. columnNum,
  69. });
  70. },
  71. onClick() {
  72. this.$emit('click');
  73. this.jumpLink();
  74. },
  75. },
  76. });
  77. export default global['__wxComponents']['vant/dist/grid-item/index']
  78. </script>
  79. <style platform="mp-weixin">
  80. @import '../common/index.css';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:flex;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{align-items:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--horizontal{flex-direction:row}.van-grid-item__content--horizontal .van-grid-item__text{margin:0 0 0 8px}.van-grid-item__content--reverse{flex-direction:column-reverse}.van-grid-item__content--reverse .van-grid-item__text{margin:0 0 8px}.van-grid-item__content--horizontal.van-grid-item__content--reverse{flex-direction:row-reverse}.van-grid-item__content--horizontal.van-grid-item__content--reverse .van-grid-item__text{margin:0 8px 0 0}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{display:flex;align-items:center;font-size:26px;font-size:var(--grid-item-icon-size,26px);height:26px;height:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}.van-grid-item__icon+.van-grid-item__text{margin-top:8px}
  81. </style>