通俗易懂的axios
get的两种请求:
methods:{ //axios.get的发送参数有两种,两个ajax请求函数都可实现 sendGetByStr(){ //1.get通过直接发字符串拼接 axios.get(`get.php?name=${this.users.name}&age=${this.users.name}`)
.then(function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); }, sendGetByObj(){ //2.get通过params选项 axios.get(`get.php?`,{ params:{ name:this.users.name, age:this.users.age } })
.then(function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); } } })
post的一种
methods:{ sendPsot(){ axios.post(‘post.php‘, { name: this.users.name, age: this.users.age, }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); } }
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/yidong/20345.html
- 上一篇:iOS处理含中文的请求链接
- 下一篇:Appium元素定位难点:tap坐标定位不准确