在vue2.0下安装axios |
您所在的位置:网站首页 › vue2安装vuex版本 › 在vue2.0下安装axios |
1.安装axios 在项目终端下 输入 npm install axios --save2.在main.js全局引入axios import axios from 'axios'; Vue.prototype.$axios=axios;3.重写WebMvcConfigurer(全局跨域) import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") //是否发送Cookie .allowCredentials(true) //放行哪些原始域 .allowedOriginPatterns("*") .allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"}) .allowedHeaders("*") .exposedHeaders("*"); } }有用的话请点一个赞,我好统计是否对你有帮助,判断是否需要补充 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |