<el-cascader size="medium" :options="options" v-model="selectOptions"(回显就是显示selectOption的值) @change="handleChange"></el-cascader>
data() { return { selectOptions: [], editForm:{} } }
//地址选择器 handleChange(value) { console.log(CodeToText[value[0]], CodeToText[value[1]], CodeToText[value[2]]) //我在本次中使用需要把省市区代码转化为文字 this.editForm.province = CodeToText[value[0]] //得到省份 this.editForm.area = CodeToText[value[1]] //得到市 this.editForm.city = CodeToText[value[2]] //得到县 },
//地址选择器回显 //把省市区文字重新转化为代码 let selected = TextToCode[row.province][row.area][row.city].code let selected1 = JSON.stringify(selected).slice(1, 3) let selected2 = JSON.stringify(selected).slice(3, 5) let selected3 = JSON.stringify(selected).slice(5, -1) console.log(selected1, selected2, selected3) let arr = [] arr.push(selected1+"0000") arr.push(selected1+selected2+"00") arr.push(selected1+selected2+selected3) console.log(arr) this.selectOptions = arr //重要,把处理后的数据重新赋值给selectOptions,让其显示
回显成功