問題所在環境:在使用若依前后端分離版框架時候遇到的問題
今天寫vue項目對接口的時候,出現了Uncaught (in promise) error 這個報錯。
我仔細看了一下,接口沒問題,
我這里好像也沒啥問題,為什么console里面會報這個錯誤呢?
后來我發現,我沒有寫catch他強行將錯誤拋出了,於是我將代碼改成以下這樣了。
但是改完之后確實不報Uncaught (in promise) error這個錯誤,改報其他錯誤了,報出一堆這樣的錯↓
報了那么一堆有的沒的錯誤,差點把我整蒙逼了。(不過不要慌,抬起二郎腿,喝杯水,繼續往下看)
.catch(err=>{ this.$message.error(err.message); console.log(err); })
在err的后面寫上message就行了。
解決方方法就是那么簡單,雖然感覺也是有些無厘頭。
以下則是報錯信息(為了方便出問題的朋友更快的鎖定問題)
vue.runtime.esm.js?a593:619 [Vue warn]: data functions should return an object:https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
(found in <Root>)warn @ vue.runtime.esm.js?a593:619initData @ vue.runtime.esm.js?a593:4709initState @ vue.runtime.esm.js?a593:4642Vue._init @ vue.runtime.esm.js?a593:5006VueComponent @ vue.runtime.esm.js?a593:5154Message @ element-ui.common.js?6255:30547main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "visible" must be accessed with "$data.visible" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30334Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "type" must be accessed with "$data.type" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30340Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "center" must be accessed with "$data.center" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30341Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "showClose" must be accessed with "$data.showClose" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30342Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "customClass" must be accessed with "$data.customClass" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30343Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "iconClass" must be accessed with "$data.iconClass" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30350Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "dangerouslyUseHTMLString" must be accessed with "$data.dangerouslyUseHTMLString" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30354Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "message" must be accessed with "$data.message" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)warn @ vue.runtime.esm.js?a593:619warnReservedPrefix @ vue.runtime.esm.js?a593:2026get @ vue.runtime.esm.js?a593:2069mainvue_type_template_id_455b9f60_render @ element-ui.common.js?6255:30356Vue._render @ vue.runtime.esm.js?a593:3548updateComponent @ vue.runtime.esm.js?a593:4066get @ vue.runtime.esm.js?a593:4479Watcher @ vue.runtime.esm.js?a593:4468mountComponent @ vue.runtime.esm.js?a593:4073Vue.$mount @ vue.runtime.esm.js?a593:8415Message @ element-ui.common.js?6255:30555main_Message.<computed> @ element-ui.common.js?6255:30576eval @ selectProject.vue?e343:127Promise.catch (async)idGetProject @ selectProject.vue?e343:126invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854Vue.$emit @ vue.runtime.esm.js?a593:3888handleClick @ element-ui.common.js?6255:9413invokeWithErrorHandling @ vue.runtime.esm.js?a593:1854invoker @ vue.runtime.esm.js?a593:2179original._wrapper @ vue.runtime.esm.js?a593:6917vue.runtime.esm.js?a593:619 [Vue warn]: Property "showClose" must be accessed with "$data.showClose" because properties starting with "$" or "_" are not proxied in the Vue instance to prevent conflicts with Vue internals. See: https://vuejs.org/v2/api/#data
(found in <Root>)