问题所在环境:在使用若依前后端分离版框架时候遇到的问题
今天写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>)