Vue-admin-template?報Uncaught?(in?promise)?error問題及解決
Vue-admin-template 報Uncaught (in promise) error
問題描述
在使用Vue-admin-template時,配置好后端,在請求時,突然報錯 而且后端接到請求了,并且返回數(shù)據(jù)了。
解決問題
找了半天,發(fā)現(xiàn)問題在request.js中。
可以發(fā)現(xiàn),是因為狀態(tài)碼不匹配,所以,直接被拋出異常了!
將狀態(tài)碼2000改成自己的成功狀態(tài)碼就OK了。
注:由于Vue-admin-template中的Ajax請求數(shù)據(jù)都是Mock.js模擬的,所以,如果要改,建議,把mock目錄中,模擬的狀態(tài)碼也一并修改!
Vue常見錯誤解決
Compiled with problems:
編譯問題
C:\myel\src\views\HomeView.vue
錯誤出現(xiàn)文件
3:1 error Mixed spaces and tabs no-mixed-spaces-and-tabs
4:1 error Mixed spaces and tabs no-mixed-spaces-and-tabs
第3行的第一個字符
第4函的第一個字符
Mixed spaces and tabs
錯誤原因:混合的空格與tab
no-mixed-spaces-and-tabs
錯誤規(guī)則: no-mixed-spaces-and-tabs 不準(zhǔn)混空格與tab
2 problems (2 errors, 0 warnings)
2個問題(2個錯誤,0個警告)
Compiled with problems:
編譯錯誤
ERROR in ./src/views/HomeView.vue?
錯誤出現(xiàn)的位置
Unexpected keyword 'const'. (6:0)
第6行第0個字符有個不應(yīng)該出現(xiàn)的關(guān)鍵字 const
63 | const user = reactive({ userid: "", pwd: "", code: "" }), | ^ 64 | const rules = reactive({ | ^ 65 | userid: [
第63到64行兩個^之間有錯誤
ERROR in ./src/router/index.ts 10:19-57
錯誤發(fā)生在 ./src/router/index.ts 第10行第19個字符到57字符
Module not found: Error: Can't resolve '../views/admin/AdminVeiw.vue' in 'C:\myel\src\router'
,模塊找不的 不能resolve(兌現(xiàn),發(fā)現(xiàn),解決)../views/admin/AdminVeiw.vue
在C:\myel\src\router
總結(jié):文件../views/admin/AdminVeiw.vue(文件名/路徑發(fā)生錯誤)
ERROR in ./src/views/HomeView.vue
錯誤發(fā)生在HomeView.vue
VueCompilerError: Element is missing end tag.
標(biāo)簽沒有結(jié)束標(biāo)簽
2 | <div class="login">
| ^
第二行的div
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')
沒有捕捉到(承諾)類型錯誤:不能夠與讀取undefined的屬性 (讀取id)
beforecreate創(chuàng)建前
created 創(chuàng)建
mounted 掛載(顯示渲染dom節(jié)點了)
<h1>{{joks[0].summary}}</h1>
joks默認(rèn)是空的
TypeError: Cannot read properties of undefined (reading 'summary')
不能夠在undefined上面讀取 summary屬性
getJok 獲取數(shù)據(jù)
觸發(fā)更新
updated 更新頁面(有數(shù)據(jù)了更新數(shù)據(jù)顯示出來了)
出現(xiàn) []下標(biāo) .屬性 用v-if (第一次不渲染,等待更新后再渲染)
Uncaught (in promise) TypeError: state.goods.forEach is not a function
對state.goods.forEach 沒有這個forEach(goods不是一個數(shù)組)
index.js
C:\youmi\src\views\AboutView.vue
出錯的文件地址
16:17 error 'reactive' is not defined no-undef
第16行17字符錯誤 reactive 沒有定義
App.vue 第30錯誤
[vuex] unknown mutation type: changeA
vuex 找不到一個叫changeA的mutations
在AboutView發(fā)生錯誤
VueCompilerError: Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).
vue編譯錯誤:屬性name 不能不包含 “ ‘ <
at C:\youmi\src\views\AboutView.vue:8:2
第8行
const 不能重復(fù)賦值
check被定義了沒有備調(diào)用
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue+Element+Springboot圖片上傳的實現(xiàn)示例
最近在學(xué)習(xí)前段后分離,本文介紹了Vue+Element+Springboot圖片上傳的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下2021-11-11Vue實現(xiàn)數(shù)據(jù)導(dǎo)入的四種方法(resource、Axios、Fetch、Excel導(dǎo)入)
本文主要介紹了Vue實現(xiàn)數(shù)據(jù)導(dǎo)入的四種方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07