在作项目时遇到需求是用户新增了内容以后,编辑此条信息的时候,要根据后台接口返回的数据进行相应的数据回显this
在表格中有多选按钮时,回显数据以下code
//获取编辑权限列表数据回显
GetEditAccount() {
editAccount(this.formLabelAlign).then(response => {
this.formLabelAlign.name = response.data.name;
this.formLabelAlign.phone = response.data.phone;
this.formLabelAlign.password = response.data.password;
this.formLabelAlign.roleId = response.data.role_id
let store_ids = response.data.store_ids;
let arr = [];
for (var i = 0; i < this.lists.length; i++) {
if(store_ids.indexOf(this.lists[i]['storeId']) == 0){
arr.push(this.lists[i]);
}
}
arr.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row);
});
})
},
关键代码orm
let store_ids = response.data.store_ids;
let arr = [];
for (var i = 0; i < this.lists.length; i++) {
if(store_ids.indexOf(this.lists[i]['storeId']) == 0){
arr.push(this.lists[i]);
}
}
arr.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row);
});