问题代码
created() {
if (this.$route.params && this.$route.params.id) {
const id = this.$route.params.id;
this.getInfo(id);//有时候这个还没加载出来下面的已经加载了
}
this.getProvinces();
},
修改后的代码(写两个getProvinces初始化就好了)
created() {
if (this.$route.params && this.$route.params.id) {
const id = this.$route.params.id;
this.getInfo(id);
} else {
this.getProvinces();
}
},
getInfo(id) {
stuApi.selectById(id).then((res) => {
res.data.stus.stuSex += "";
this.student = res.data.stus;
this.getProvinces();
});
},