错误:
ERROR
Network Error
AxiosError@webpack-internal:///./node_modules/axios/lib/core/AxiosError.js:23:18
handleError@webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:155:14
EventHandlerNonNull*dispatchXhrRequest@webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:152:5
__webpack_exports__.default<@webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:57:10
dispatchRequest@webpack-internal:///./node_modules/axios/lib/core/dispatchRequest.js:53:10
promise callback*request@webpack-internal:///./node_modules/axios/lib/core/Axios.js:117:27
forEachMethodNoData/Axios.prototype[method]@webpack-internal:///./node_modules/axios/lib/core/Axios.js:157:17
wrap@webpack-internal:///./node_modules/axios/lib/helpers/bind.js:9:15
mounted@webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/HomeView.vue?vue&type=script&lang=js&:22:60
invokeWithErrorHandling@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2889:57
callHook$1@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3862:30
insert@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4227:17
invokeInsertHook@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:6518:30
patch@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:6706:21
lifecycleMixin/Vue.prototype._update@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3605:19
updateComponent@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3703:10
Watcher</Watcher.prototype.get@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3295:27
Watcher</Watcher.prototype.run@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3366:24
flushSchedulerQueue@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3949:13
nextTick/<@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3008:12
flushCallbacks@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2936:14
promise callback*timerFunc@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2961:9
nextTick@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3018:5
queueWatcher@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4031:13
Watcher</Watcher.prototype.update@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3357:19
Dep</Dep.prototype.notify@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:761:11
reactiveSetter@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:971:13
init/</<@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2503:7
init/<@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2502:19
updateRoute@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2031:19
transitionTo/<@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1898:14
confirmTransition/</<@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2020:17
step@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1746:7
step@webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1753:13
怎么解决
不知道为什么,明明已经加了注解@CrossOrigin,但是还是跨域问题,数据不响应!文章来源:https://www.toymoban.com/news/detail-767208.html
还是加了配置才可以访问文章来源地址https://www.toymoban.com/news/detail-767208.html
package com.xtc.common;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class CorsConfig {
// 当前跨域请求最大有效时长。这里默认1天
private static final long MAX_AGE = 24 * 60 * 60;
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
corsConfiguration.setMaxAge(MAX_AGE);
source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
return new CorsFilter(source);
}
}
到了这里,关于ERRORNetwork ErrorAxiosError@webpack-internal:///./node_modules/axios/lib/core/AxiosError.js:23:18的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!