1.停止启动的脚手架工程 命令行中执行 npm i axios -S
2.在main.js中导入
//引入Axios
import axios from 'axios'
//Vue.prototype.xxx 给Vue添加一个全局的变量
// 添加的全局变量可以在任意的*.vue文件中通过this.xxx访问
Vue.prototype.axios=axios
3.请求代码
function(){
//发出异步请求
this.axiso.post("url",data).then((response)=>
//response代表响应对象 response.data服务器响应的数据
//response.data=服务器响应的JsonResult对象
if(response.data.code==1){
this.$router.push("/")
}else{
this.$message.error(response.data.msg);
}
})