forked from N3-components/N3-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn3FormItem.vue
51 lines (48 loc) · 939 Bytes
/
n3FormItem.vue
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
47
48
49
50
51
<template>
<div :class="classObj" >
<label class="{{prefixCls}}-col-sm-{{labelCol}} {{prefixCls}}-control-label">
<em class="{{prefixCls}}-form-need" v-if="need" >*</em>
{{label}}
</label>
<div class="{{prefixCls}}-col-sm-{{col}}">
<slot></slot>
</div>
</div>
</template>
<script>
export default {
props: {
label: {
type: String
},
labelCol: {
type: Number,
default: 2
},
wrapCol: {
type: Number
},
need: {
type: Boolean,
default: false
},
prefixCls: {
type: String,
default: 'n3'
}
},
computed: {
col () {
return 12 - this.labelCol
},
classObj () {
let {prefixCls, wrapCol} = this
let klass = {}
klass['clearfix'] = true
klass[prefixCls + '-form-group'] = true
wrapCol ? klass[prefixCls + '-col-sm-' + wrapCol] = true : ''
return klass
}
}
}
</script>