赞
踩
当data中默认没有定义form.region的值时,会出现选择select后input没有回显选择数据值;所以使用select时,必须定义默认值
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="活动名称">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="活动区域">
<el-select v-model="form.region" placeholder="请选择活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
</el-form>
<script>
export default {
data() {
return {
form: {
name: '',
region: ''
}
}
},
methods: {
onSubmit() {
console.log('submit!');
}
}
}
</script>
强制重新加载页面@visible-change=“$forceUpdate()”
<el-form ref="form" :model="form" :rules="rules" label-width="80px" size="small">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注"/>
</el-form-item>
<el-row v-for="(item,index) in form.details" :key="index">
<el-col :span="12">
<el-form-item label="活动区域" :prop="'details['+index+']region'" label-width="75px">
<el-select v-model="form.region" placeholder="请选择活动区域" @visible-change="$forceUpdate()">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否启用" :prop="'details['+index+']status'" label-width="75px">
<el-switch v-model="item.status" active-value="Y" inactive-value="N" @change="$forceUpdate()"></el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form>
//也可在方法中使用
methods:{
update(){
this.$forceUpdate();//强制刷新视图
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。