forked from youzan/vant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (38 loc) · 869 Bytes
/
index.js
File metadata and controls
44 lines (38 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { createNamespace } from '../utils';
const [createComponent, bem] = createNamespace('col');
export default createComponent({
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 } : {};
}
},
methods: {
onClick(event) {
this.$emit('click', event);
}
},
render() {
const { span, offset } = this;
return (
<this.tag
style={this.style}
class={bem({ [span]: span, [`offset-${offset}`]: offset })}
onClick={this.onClick}
>
{this.slots()}
</this.tag>
);
}
});