1:在a頁面有個el-cascader,級聯選擇,選擇完后綁定值為數組[1,2,3]並發送給后端
2:在b頁面的el-cascader需要進入頁面先回顯出來。但是數據是字符串(后端處理了數據)"1,2,3"
3:出現了回顯不了問題:進入數據賦值form.complaintype回顯不了
4:解決方案:把字符串轉成數組,並且,一定要注意接收
html: <el-form-item label="投訴類型"> <el-cascader v-model="form.complainType" :options="options" ></el-cascader> </el-form-item> methods: formatTreeDate(data) { var str = data.complainType; console.log(str); str = str.split(",") this.form.complainType = str console.log(this.form.complainType) }, getAcceptInfo(dialogId) { this.$axios .post(this.$apis.ccweb.newDataSL.selectAcceptInfoById, { dialogId }) .then((res) => { const { code, data } = res; if (code === 200 && data) { console.log(data); this.form = data; this.formatTreeDate(data); this.showPrise = false; this.showRentPrise = true; } else { this.showPrise = true; this.showRentPrise = false; } }); console.log("this.acceptInfo", this.acceptInfo); },
這樣就能回顯了