12345678910111213141516171819202122232425262728293031323334353637 |
- import { VantComponent } from '../common/component';
- VantComponent({
- relation: {
- name: 'col',
- type: 'descendant',
- linked(target) {
- if (this.data.gutter) {
- target.setGutter(this.data.gutter);
- }
- }
- },
- props: {
- gutter: Number
- },
- watch: {
- gutter: 'setGutter'
- },
- mounted() {
- if (this.data.gutter) {
- this.setGutter();
- }
- },
- methods: {
- setGutter() {
- const { gutter } = this.data;
- const margin = `-${Number(gutter) / 2}px`;
- const style = gutter
- ? `margin-right: ${margin}; margin-left: ${margin};`
- : '';
- this.set({ style });
- this.getRelationNodes('../col/index').forEach(col => {
- col.setGutter(this.data.gutter);
- });
- }
- }
- });
|