需要在编辑方法中传递正确的 catId
。通常,编辑方法应该接收一个参数,该参数包含了你点击的节点的数据,其中应该包含 catId
。然后,你可以从这个参数中获取正确的 catId
并赋值给 category.catId
。
只需要在src\views\modules\product\category.vue下的
edit(data) {……}中加
this.category.catId = data.catId;将变量保存。
edit(data) {
console.log("要修改的数据", data);
this.dialogType = "edit";
this.title = "修改分类";
this.dialogVisible = true;
this.category.catId = data.catId;
//发送请求获取当前节点最新的数据
this.$http({
url: this.$http.adornUrl(`/product/category/info/${data.catId}`),
method: "get"
}).then(({ data }) => {
//请求成功
console.log("要回显的数据", data);
this.category.name = data.data.name;
this.category.catId = data.data.catId;
this.category.icon = data.data.icon;
this.category.productUnit = data.data.productUnit;
this.category.parentCid = data.data.parentCid;
this.category.catLevel = data.data.catLevel;
this.category.sort = data.data.sort;
this.category.showStatus = data.data.showStatus;
/**
* parentCid: 0,
catLevel: 0,
sort: 0,
*/
});