关于element-ui中使用el-form中,在父元素设置初始值,子元素中form数据改变,视图不变的解决方案
文章目录
form是一个引用类型,有时候form中的属性值变化,并不会直接引起父元素视图的变化,可以将初始值设为空对象,再再请求到数据之后变换初始值为请求后的值,这样会引起视图的变化。
{
type: 'select',
key: 'imageId',
width: '240px',
label: '镜像选择',
initValue: [],
options: this.imageList.map(item => {
return {
label: item.name,
value: item.id,
};
}),
},
async getClusterList() {
const res = await this.$api.post(
`${_clusterList}/2`,
);
this.clusterList = res;
this.softwareIndexForm.clusterType = res[0];
this.softwareIndexFormList[0].initValue = res[0];
},
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论