【发布时间】:2021-08-17 13:22:34
【问题描述】:
当我的页面第一次加载时,我的 vue.js 页面中有一个挂载函数 this.editId 变量包含值,但第二次和第三次也自动调用挂载函数,这表明
app.js:1088 GET http://localhost:8000/api/backend/bill/undefined 404 (Not Found)
但我第一次在控制台中获取 editId 值。
export default {
components: {
Datepicker,datetime
},
async mounted(){
const header = {
'Authorization': 'Bearer ' + this.LoginUserData,
};
this.editId = this.$route.params.id;
try{
console.log(this.editId);
let response = await axios.get(`/api/backend/bill/${this.editId}` ,{headers: header});
this.form = response.data;
}catch(err){
}
},
任何解决方案,谢谢
【问题讨论】:
-
抱歉,我想确认一下。您的问题是该挂载多次调用吗?还是多次刷新页面时this.editId的值有问题?
标签: vue.js vuejs2 vue-router