mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[improvement] Col: jsx (#2500)
This commit is contained in:
34
packages/col/index.js
Normal file
34
packages/col/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { use } from '../utils';
|
||||
|
||||
const [sfc, bem] = use('col');
|
||||
|
||||
export default sfc({
|
||||
props: {
|
||||
span: [Number, String],
|
||||
offset: [Number, String],
|
||||
tag: {
|
||||
type: String,
|
||||
default: 'div'
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
gutter() {
|
||||
return (this.$parent && Number(this.$parent.gutter)) || 0;
|
||||
},
|
||||
|
||||
style() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user