refactor(Row): use setup

This commit is contained in:
chenjiahan
2020-08-24 15:53:26 +08:00
parent 804a4e0193
commit 6375fe5169
2 changed files with 44 additions and 46 deletions
+14 -14
View File
@@ -16,25 +16,25 @@ export default createComponent({
},
setup(props, { slots }) {
const getStyle = (vm) => {
const { index } = vm;
const { spaces } = vm.parent || {};
if (spaces && spaces[index]) {
const { left, right } = spaces[index];
return {
paddingLeft: left ? `${left}px` : null,
paddingRight: right ? `${right}px` : null,
};
}
};
return (vm) => {
const { tag, span, offset } = props;
const getStyle = () => {
const { index } = vm;
const { spaces } = vm.parent || {};
if (spaces && spaces[index]) {
const { left, right } = spaces[index];
return {
paddingLeft: left ? `${left}px` : null,
paddingRight: right ? `${right}px` : null,
};
}
};
return (
<tag
style={getStyle()}
style={getStyle(vm)}
class={bem({ [span]: span, [`offset-${offset}`]: offset })}
>
{slots.default?.()}