var vm = new Vue({
el: '#mainIndex',
data: {
session_id: "",
_type_id: 0,
id: 0,
videoImage: "",
picUrl: "",
jumpUrl: "",
videoUrl: "",
videoCnt: "",
videoNum: "",
videoExtList: {}
},
methods: {
getData: function () {
let that = this;
let data = {
session_id: that.session_id,
platform: platform,
id: that.id,
_type_id: tphat._type_id,
}
axios
.post("/api/v1/video/idx", data) // .post(或者get之类的)这里是request请求 是我给后端数据 所以data里的是我可以给后端的东西 比如 后端要我给他platform 那我就写在data里 就可以传给后端了
.then(function (ev) { // .then是response请求 是后端给我的东西 所以我要获取后端的数据内容 就要在这里取出来
var datas = ev.data.data;
if (ev.data.statusCode == 200) {
that.id = datas.id;
that.picUrl = datas.picUrl;
that.jumpUrl = datas.jumpUrl;
that.videoUrl = datas.videoUrl;
that.videoCnt = datas.videoCnt;
that.videoTitle = datas.videoTitle;
that.videoImage = datas.videoImage;
that.videoExtList = datas.videoExtList;
}
})
.catch(function (error) {
console.log(error);
});
}
},
mounted() {
this.getData();
}
})
//① request请求之前拦截
//____________________________
//② request 给后端发数据
//③ response 后端给我数据
//_____________________________
//④ response请求之后拦截
//⑤ 方法
网友评论