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
46 lines (41 loc) · 929 Bytes
/
index.js
File metadata and controls
46 lines (41 loc) · 929 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
45
46
import { createNamespace } from '../utils';
const [createComponent, bem] = createNamespace('row');
export default createComponent({
props: {
type: String,
align: String,
justify: String,
tag: {
type: String,
default: 'div'
},
gutter: {
type: [Number, String],
default: 0
}
},
methods: {
onClick(event) {
this.$emit('click', event);
}
},
render() {
const { align, justify } = this;
const flex = this.type === 'flex';
const margin = `-${Number(this.gutter) / 2}px`;
const style = this.gutter ? { marginLeft: margin, marginRight: margin } : {};
return (
<this.tag
style={style}
class={bem({
flex,
[`align-${align}`]: flex && align,
[`justify-${justify}`]: flex && justify
})}
onClick={this.onClick}
>
{this.slots()}
</this.tag>
);
}
});