1.数据格式
代码语言:javascript复制{"data":[{"username":"xxx","avatar":"xxx","gift_name":"xxx"},{"username":"xxx","avatar":"xxx","gift_name":"xxx"},{"username":"xxx","avatar":"xxx","gift_name":"xxx"},{"username":"xxx","avatar":"xxx","gift_name":"xxx"},{"username":"xxx","avatar":"xxx","gift_name":"xxx"}]}
2.取值
代码语言:javascript复制username data[0].username
avatar data[0].avatar
3.vue接口请求后
代码语言:javascript复制this.getPrizeUser()
.then(ret => {
setInterval((i => (() =>{
if(i>ret.data.length)i=0;
this.$refs.danmu.render(ret.data[i].avatar,ret.data[i].username,'获得了',ret.data[i].gift_name, 1000);
i ;
}))(0),11000);
})
.catch(err => {
this.$toast.fail("系统开小差,请重试");
});