表单默认值
... 2022-3-28 Less than 1 minute
# 表单默认值
# 配置方法
配置value
为字段默认值
<avue-form :option="option" v-model="form" > </avue-form>
<script>
export default{
data() {
return {
form: {},
option: {
column: [
{
label: '姓名',
prop: 'name',
value:'small'
}
]
}
}
}
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Expand Copy Copy
# 赋值方法
利用v-model
绑定的对象直接操作即可
<el-button @click="changeText" size="small" type="success">改变值</el-button>
<br/><br/>
<avue-form :option="option" v-model="form" > </avue-form>
<script>
export default{
data() {
return {
form: {
name:'small'
},
option: {
column: [
{
label: '姓名',
prop: 'name'
}
]
}
}
},
methods:{
changeText(){
this.form.name="我改变了"
}
}
}
</script>
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
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
Expand Copy Copy