1、场景描述
这里展示的是已经获得后台传回来的需要回显数据,在级联选择器中进行回显,并且能保持稳定回显
2、解决办法
2.1、在el-cascader标签中加入
:key=“modalKey”
v-model=“choose”
2.2、在data中定义
data() { //定义变量和初始值
return{
modalKey: 0,
choose: [],
}
},
2.3、赋值
参考以下代码
methods:{ //创建具体的方法,
getInfo() {
course.getCourseInfoId(this.courseId).then((response) => {
//在courseInfo课程基本信息,包含 一级分类id 和 二级分类id
this.courseInfo = response.data.courseInfoVo;
//下标0为一级菜单value
this.choose[0] = this.courseInfo.subjectParentId;
//下标1为二级菜单value
this.choose[1] = this.courseInfo.subjectId;