若依 select回显
时间: 2023-08-23 10:12:40 浏览: 125
根据引用\[1\]和引用\[3\]的内容,若依 select组件的回显可以通过以下方法实现:
在点击编辑对表格数据进行复制的接口里,可以使用`this.$set`方法来设置`userForm`对象的`roleIds`属性,将角色数据进行处理后赋值给`roleIds`。具体操作如下:
```javascript
getUserDetail(userId) {
apiUserDetail({ userId: userId })
.then((res) => {
if (res.retcode === "000000") {
let changeData = { ...res.data };
// 角色数据处理
let roleIdArr = \[\];
changeData.roles.map((item) => roleIdArr.push(item.roleId));
this.$set(this.userForm, "roleIds", roleIdArr);
delete this.userForm.roles; // 释放详情接口数据角色内存
} else {
this.msgError(res.retinfo);
}
})
.catch((err) => {
this.msgError("请求失败请重试");
})
.finally(() => {});
},
```
这样就可以实现若依 select组件的回显。
#### 引用[.reference_title]
- *1* *3* [处理select选择器回显数据后dom元素无法操作问题](https://blog.csdn.net/bruno_mars_brother/article/details/118419359)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [若依+Thymeleaf 获取复选框参数和回显](https://blog.csdn.net/torpidcat/article/details/100120390)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文