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 不準混空格與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個字符有個不應該出現(xià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
總結:文件../views/admin/AdminVeiw.vue(文件名/路徑發(fā)生錯誤)

ERROR in ./src/views/HomeView.vue
錯誤發(fā)生在HomeView.vue
VueCompilerError: Element is missing end tag.
標簽沒有結束標簽
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默認是空的

TypeError: Cannot read properties of undefined (reading 'summary')
不能夠在undefined上面讀取 summary屬性
getJok 獲取數(shù)據(jù)
觸發(fā)更新
updated 更新頁面(有數(shù)據(jù)了更新數(shù)據(jù)顯示出來了)
出現(xiàn) []下標 .屬性 用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 不能重復賦值

check被定義了沒有備調用
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Vue3中實現(xiàn)拖拽和縮放自定義看板 vue-grid-layout的方法
這篇文章主要介紹了Vue3中實現(xiàn)拖拽和縮放自定義看板 vue-grid-layout的方法,本文結合實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03
Vue2中pinia刷新后數(shù)據(jù)丟失的問題解決
Pinia是一個Vue.js狀態(tài)管理庫,如果你在組件中修改了store中的數(shù)據(jù)并刷新了界面,Pinia會將store中的數(shù)據(jù)重置為初始值,從而導致數(shù)據(jù)丟失的問題,本文就來介紹一下問題解決,感興趣的可以了解一下2023-12-12

