index.vue 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <uni-shadow-root class="vant-row-index"><view class="custom-class van-row" :style="style">
  3. <slot></slot>
  4. </view></uni-shadow-root>
  5. </template>
  6. <script>
  7. global['__wxRoute'] = 'vant/row/index'
  8. import { VantComponent } from '../common/component';
  9. VantComponent({
  10. relation: {
  11. name: 'col',
  12. type: 'descendant',
  13. linked(target) {
  14. if (this.data.gutter) {
  15. target.setGutter(this.data.gutter);
  16. }
  17. }
  18. },
  19. props: {
  20. gutter: Number
  21. },
  22. watch: {
  23. gutter: 'setGutter'
  24. },
  25. mounted() {
  26. if (this.data.gutter) {
  27. this.setGutter();
  28. }
  29. },
  30. methods: {
  31. setGutter() {
  32. const { gutter } = this.data;
  33. const margin = `-${Number(gutter) / 2}px`;
  34. const style = gutter
  35. ? `margin-right: ${margin}; margin-left: ${margin};`
  36. : '';
  37. this.set({ style });
  38. this.getRelationNodes('../col/index').forEach(col => {
  39. col.setGutter(this.data.gutter);
  40. });
  41. }
  42. }
  43. });
  44. export default global['__wxComponents']['vant/row/index']
  45. </script>
  46. <style platform="mp-weixin">
  47. @import '../common/index.css';.van-row:after{content:"";display:table;clear:both}
  48. </style>