您的位置:首页 > Web前端 > Vue.js

vue 的axios请求数据2种方式 很重要

2018-10-19 10:28 615 查看
[code]

show:function(){
//post 方式
//赋值给变量self   //使用axios  请求后台的数据    get和post的两种方式
var self=this;
var url='xxxx.json';
axios.post(url,{
params:{
username:"yyyyy",
password:'18888'
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
})
},
show: function(){
//get方式
//赋值给变量self
var self = this;
var url = "hotcity.json";
axios.get(url,{
params:{
username: "金星老师"
}
}).then(function (response) {
self.stu = response.data.data.hotCity;
console.log(response.data.data.hotCity);
}).catch(function (error) {
console.log(error);
})
},

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: