mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-06-02 19:59:16 +08:00
refactor(Col): use setup
This commit is contained in:
parent
4d9b4b3e23
commit
804a4e0193
@ -15,39 +15,31 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['click'],
|
setup(props, { slots }) {
|
||||||
|
return (vm) => {
|
||||||
|
const { tag, span, offset } = props;
|
||||||
|
|
||||||
computed: {
|
const getStyle = () => {
|
||||||
style() {
|
const { index } = vm;
|
||||||
const { index } = this;
|
const { spaces } = vm.parent || {};
|
||||||
const { spaces } = this.parent || {};
|
|
||||||
|
|
||||||
if (spaces && spaces[index]) {
|
if (spaces && spaces[index]) {
|
||||||
const { left, right } = spaces[index];
|
const { left, right } = spaces[index];
|
||||||
return {
|
return {
|
||||||
paddingLeft: left ? `${left}px` : null,
|
paddingLeft: left ? `${left}px` : null,
|
||||||
paddingRight: right ? `${right}px` : null,
|
paddingRight: right ? `${right}px` : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
return (
|
||||||
onClick(event) {
|
<tag
|
||||||
this.$emit('click', event);
|
style={getStyle()}
|
||||||
},
|
class={bem({ [span]: span, [`offset-${offset}`]: offset })}
|
||||||
},
|
>
|
||||||
|
{slots.default?.()}
|
||||||
render() {
|
</tag>
|
||||||
const { span, offset } = this;
|
);
|
||||||
return (
|
};
|
||||||
<this.tag
|
|
||||||
style={this.style}
|
|
||||||
class={bem({ [span]: span, [`offset-${offset}`]: offset })}
|
|
||||||
onClick={this.onClick}
|
|
||||||
>
|
|
||||||
{this.$slots.default?.()}
|
|
||||||
</this.tag>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user