博客内容为了方便以后自己操作,毕竟我并非前端开发工程师,所以操作的不会太多,为了方便下次使用,权做记录。
在网上找到各种跨域的方法,从前端到后端,各种设置,挺麻烦的。这应该是最简单的处理方法了,重点在于POST请求的 new URLSearchParams()
1.安装 npm install axios
2.设置
2.1main.js
import axios from 'axios'
Vue.prototype.$axios = axios
Vue.prototype.HOST='/api'
2.2index.js
proxyTable: { '/api': { //使用"/api"来代替"http://localhost:8080/mongodb" target: 'http://localhost:8080/mongodb', //跨域访问地址 changeOrigin: true, //改变源 pathRewrite: { '^/api': '' } } },