安装 axios
npm install --save axios
配置 axios
调用方法里写:
//请求的url 地址
const url = 'http://192.168.123.130:8085/account/message/send'
//使用URLSerchParms来处理参数,URLSerchParams的兼容性较差,注意:(可使用babel来转换)
var params = new URLSearchParams()
// 请求的参数(可多个)
params.append('phone',this.phone)
this.$axios({
method: 'post', // 请求方式
url: url, //请求链接
data: params
}).then((res) =>{
console.log(res)
}).catch((res) => {
console.log(' 请求失败 ' + res)
})