vue axios springboot 跨域
生活随笔
收集整理的這篇文章主要介紹了
vue axios springboot 跨域
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
假設springboot開發的應用運行在http://localhost:8081, 獲取用戶的查詢接口為/users.
webpack devServer運行在http://localhost:8080
修改webpack的配置文件config/index.js
dev:{
proxyTable:{
'/api':{
target:'http://localhost:8081',
changeOrigin:true,
pathRewrite:{
'^/api':'/'
}
}
}
}
修改main.js引入axios
import axios from 'axios'
Vue.prototype.$http = axios
發送請求
this.$http.get('/api/users').then((res) => {
this.users = res.data.users
})
總結
以上是生活随笔為你收集整理的vue axios springboot 跨域的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Go web framework
- 下一篇: html5倒计时秒杀怎么做,vue 设