index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <uni-shadow-root class="weapp-lib-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'] = 'weapp/lib/grid-item/index'
  25. "use strict";
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. var component_1 = require("../common/component");
  28. var relation_1 = require("../common/relation");
  29. var link_1 = require("../mixins/link");
  30. (0, component_1.VantComponent)({
  31. relation: (0, relation_1.useParent)('grid'),
  32. classes: ['content-class', 'icon-class', 'text-class'],
  33. mixins: [link_1.link],
  34. props: {
  35. icon: String,
  36. iconColor: String,
  37. iconPrefix: {
  38. type: String,
  39. value: 'van-icon',
  40. },
  41. dot: Boolean,
  42. info: null,
  43. badge: null,
  44. text: String,
  45. useSlot: Boolean,
  46. },
  47. data: {
  48. viewStyle: '',
  49. },
  50. mounted: function () {
  51. this.updateStyle();
  52. },
  53. methods: {
  54. updateStyle: function () {
  55. if (!this.parent) {
  56. return;
  57. }
  58. var _a = this.parent, data = _a.data, children = _a.children;
  59. var columnNum = data.columnNum, border = data.border, square = data.square, gutter = data.gutter, clickable = data.clickable, center = data.center, direction = data.direction, reverse = data.reverse, iconSize = data.iconSize;
  60. this.setData({
  61. center: center,
  62. border: border,
  63. square: square,
  64. gutter: gutter,
  65. clickable: clickable,
  66. direction: direction,
  67. reverse: reverse,
  68. iconSize: iconSize,
  69. index: children.indexOf(this),
  70. columnNum: columnNum,
  71. });
  72. },
  73. onClick: function () {
  74. this.$emit('click');
  75. this.jumpLink();
  76. },
  77. },
  78. });
  79. export default global['__wxComponents']['weapp/lib/grid-item/index']
  80. </script>
  81. <style platform="mp-weixin">
  82. @import '../common/index.css';.van-grid-item{box-sizing:border-box;float:left;position:relative}.van-grid-item--square{height:0}.van-grid-item__content{background-color:var(--grid-item-content-background-color,#fff);box-sizing:border-box;display:flex;flex-direction:column;height:100%;padding:var(--grid-item-content-padding,16px 8px)}.van-grid-item__content:after{border-width:0 1px 1px 0;z-index:1}.van-grid-item__content--surround:after{border-width:1px}.van-grid-item__content--center{align-items:center;justify-content:center}.van-grid-item__content--square{left:0;position:absolute;right:0;top: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:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{align-items:center;display:flex;font-size:var(--grid-item-icon-size,26px);height:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:var(--grid-item-text-color,#646566);font-size:var(--grid-item-text-font-size,12px)}.van-grid-item__icon+.van-grid-item__text{margin-top:8px}
  83. </style>