将请求接口定义定义成全局变量,挂载到vue实例上可以全局使用,
随便写一个文件放请求接口,并导出。
在 main.js 文件中导入,并挂载。这样就可以在项目里使用。
使用案例
this.GLOBAL.myhf 调用的接口
login:地址
参数
username:,
password:
axios .post( this.GLOBAL.myhf + "/login", qs.stringify({
username: that.formData.user.username,
password: that.formData.user.password
}), { withCredentials: true } ) .then(function(response) {
输出数据
console.log(response)
})
多参数拼接
前台拿到的数据
this.info.pageNumber
后台参数
pageNum
pageNum<