第一次加載頁面時出現錯誤。我在該組件中有以下代碼。<router-link :to="{ name: 'play', params: { token: this.$route.params.token, id: user.id } }" target="_blank" > <button class="btn btn-warning fz-btn-play"> <i class="fas fa-play"></i> </button></router-link>當頁面首次加載時 user.id 給出錯誤,因為它加載時用戶變量為空。錯誤是 TypeError: Cannot read property 'id' of null然后我運行 created() 方法:created() { axios.get("/api/getUser").then((response) => { this.user = response.data; });},當頁面完全加載時,它工作正常,但控制臺中顯示錯誤如何刪除此錯誤。
在 VueJS 和 Laravel 混合中呈現錯誤
慕神8447489
2022-06-16 10:21:41