当前位置: 首页 > Web前端 > vue.js

关于element-ui中el-form的使用,在父元素中设置初始值,在子元素中更改表单数据,view保持不变

时间:2023-03-31 20:28:42 vue.js

form是引用类型。有时表单中的属性值发生变化,并不会直接引起父元素视图的变化。可以将初始值设置为一个空对象,然后在请求数据后将初始值改为请求的值,这样会引起视图的变化。{type:'select',key:'imageId',width:'240px',label:'镜像选择',initValue:[],options:this.imageList.map(item=>{return{label:item.name,值:item.id,};}),},asyncgetClusterList(){constres=awaitthis.$api.post(`${_clusterList}/2`,);this.clusterList=res;this.softwareIndexForm.clusterType=res[0];this.softwareIndexFormList[0].initValue=res[0];},