VUE导入拦截器报错Uncaught runtime errors:ERRORNetwork ErrorAxiosError: Network Error

Uncaught runtime errors:

×

ERROR

Network Error AxiosError: Network Error at XMLHttpRequest.handleError (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:112:14) at Axios.request (webpack-internal:///./node_modules/axios/lib/core/Axios.js:54:41)

HomeView.vue:29  

TypeError: (0 , _utils_request__WEBPACK_IMPORTED_MODULE_0__.default)(...).get is not a function
    at VueComponent.mounted (VM7442 HomeView.vue:23:66)
    at invokeWithErrorHandling (vue.runtime.esm.js:3033:1)
    at callHook$1 (vue.runtime.esm.js:4048:1)
    at Object.insert (vue.runtime.esm.js:4443:1)
    at invokeInsertHook (vue.runtime.esm.js:6966:1)
    at VueComponent.patch [as __patch__] (vue.runtime.esm.js:7180:1)
    at Vue._update (vue.runtime.esm.js:3785:1)
    at VueComponent.updateComponent (vue.runtime.esm.js:3891:1)
    at Watcher.get (vue.runtime.esm.js:3462:1)
    at Watcher.run (vue.runtime.esm.js:3538:1)


 


 


check @ dev-server.js:15
eval @ dev-server.js:69
emit @ events.js:153
reloadApp @ reloadApp.js:38
ok @ index.js:227
eval @ socket.js:62
client.onmessage @ WebSocketClient.js:45
显示 31 更多框架
显示简略信息
HomeView.vue:29  TypeError: (0 , _utils_request__WEBPACK_IMPORTED_MODULE_0__.default)(...).get is not a function
    at VueComponent.mounted (HomeView.vue:141:1)
    at invokeWithErrorHandling (vue.runtime.esm.js:3033:1)
    at callHook$1 (vue.runtime.esm.js:4048:1)
    at Object.insert (vue.runtime.esm.js:4443:1)
    at invokeInsertHook (vue.runtime.esm.js:6966:1)
    at VueComponent.patch [as __patch__] (vue.runtime.esm.js:7180:1)
    at Vue._update (vue.runtime.esm.js:3785:1)
    at VueComponent.updateComponent (vue.runtime.esm.js:3891:1)
    at Watcher.get (vue.runtime.esm.js:3462:1)
    at Watcher.run (vue.runtime.esm.js:3538:1)
logError @ vue.runtime.esm.js:3065
globalHandleError @ vue.runtime.esm.js:3057
handleError @ vue.runtime.esm.js:3024
invokeWithErrorHandling @ vue.runtime.esm.js:3040
callHook$1 @ vue.runtime.esm.js:4048
insert @ vue.runtime.esm.js:4443
invokeInsertHook @ vue.runtime.esm.js:6966
patch @ vue.runtime.esm.js:7180
Vue._update @ vue.runtime.esm.js:3785
updateComponent @ vue.runtime.esm.js:3891
Watcher.get @ vue.runtime.esm.js:3462
Watcher.run @ vue.runtime.esm.js:3538
flushSchedulerQueue @ vue.runtime.esm.js:4141
eval @ vue.runtime.esm.js:3159
flushCallbacks @ vue.runtime.esm.js:3081
Promise.then
timerFunc @ vue.runtime.esm.js:3106
nextTick @ vue.runtime.esm.js:3171
queueWatcher @ vue.runtime.esm.js:4227
Watcher.update @ vue.runtime.esm.js:3529
Vue.$forceUpdate @ vue.runtime.esm.js:3810
eval @ index.js:244
eval @ index.js:242
eval @ index.js:119
eval @ HomeView.vue:29
./src/views/HomeView.vue @ src_views_HomeView_vue.js:18
__webpack_require__ @ app.js:182
_requireSelf @ app.js:490
apply @ app.js:1226
(匿名) @ app.js:730
internalApply @ app.js:728
(匿名) @ app.js:666
waitForBlockingPromises @ app.js:621
(匿名) @ app.js:664
Promise.then
(匿名) @ app.js:663
Promise.then
(匿名) @ app.js:644
Promise.then
hotCheck @ app.js:635
check @ dev-server.js:15
eval @ dev-server.js:69
emit @ events.js:153
reloadApp @ reloadApp.js:38
ok @ index.js:227
eval @ socket.js:62
client.onmessage @ WebSocketClient.js:45
显示 30 更多框架
显示简略信息
localhost/:1  Access to XMLHttpRequest at 'http://localhost:8080/' from origin 'http://localhost:7000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
request.js:46 AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} 'error'
HomeView.vue:141 
        
Access to XMLHttpRequest at 'http://localhost:8080/' from origin 'http://localhost:7000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

VM7442 HomeView.vue:23 
GET http://localhost:8080/ net::ERR_FAILED 200 (OK)


Axios.js:61  Uncaught (in promise) AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}

解决方法:

request.get('/user/selectAll').then( res => {
  this.users = res.data
  // console.log(res.data) //后台返回的数据
})

写成了

request().get('/user/selectAll').then( res => {
  this.users = res.data
  // console.log(res.data) //后台返回的数据
})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值