原因:不能直接使用 axios.get(),会提示axios is not defined
1,下载
npm install axios
2,引入
在man.js中添加
import axios from 'axios'
Vue.prototype.axios = axios;
3,使用
官网使用方法:
Vue.axios.get(api).then((response) => {
console.log(response.data)
})
this.axios.get(api).then((response) => {
console.log(response.data)
})
this.$http.get(api).then((response) => {
console.log(response.data)
})
用this方式访问
this.axios.post("http://localhost:8080/login", this.user)