1.安装axios npm i axios --s
2.nin.js中引用
import axios from 'axios'
Vue.prototype.$http=axios
设置请求根路径:
axios.defaults.baseUrl='http://hd215.api.yesapi.cn/'
3.基本使用:
this.$http.get('s=App.User.Login',{
params:{
app_key:'4A2D409CA0645B01E5B6F0D60F3AE200',
username:this.username,
password:'ecb97ffafc1798cd2f67fcbc37226761'
}
}).then((res)=>{
console.log(res.data)
if(res.data.ret==200){
console.log("登陆成功")
//保存token
window.sessionStorage.setItem('token',res.data.data.err_code);
this.$router.push('/home')
}else{
this.tishi="登录失败"
}
})