[improvement] Col: jsx (#2500)

This commit is contained in:
neverland 2019-01-11 22:36:26 +08:00 committed by GitHub
parent 7a19675e1f
commit 9e01b1ef16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,19 +1,8 @@
<template>
<component
:is="tag"
:class="b({ [span]: span, [`offset-${offset}`]: offset })"
:style="style"
>
<slot />
</component>
</template>
import { use } from '../utils';
<script>
import create from '../utils/create';
export default create({
name: 'col',
const [sfc, bem] = use('col');
export default sfc({
props: {
span: [Number, String],
offset: [Number, String],
@ -32,6 +21,14 @@ export default create({
const padding = `${this.gutter / 2}px`;
return this.gutter ? { paddingLeft: padding, paddingRight: padding } : {};
}
},
render(h) {
const { span, offset } = this;
return (
<this.tag class={bem({ [span]: span, [`offset-${offset}`]: offset })} style={this.style}>
{this.$slots.default}
</this.tag>
);
}
});
</script>