从后台获取的数据,已经渲染到页面上了,控制台还是报undefined的错误
<div class="slider">
<div class="item" >
<transition name="slider-trans" >
<img v-if="isShow" :src='sliders[nowIndex].picUrl'>
</transition>
</div>
</div>
export default{
data (){
return{
sliders: [],
nowIndex: 0,
isShow: true
}
},
created(){
this._getRecommend(),
},
methods: {
_getRecommend(){
getRecommend().then((res)=>{
if(res.code==0){
console.log(res.data.slider);
var slidesArr = res.data.slider;
for (let i = 0;i < slidesArr.length;i++) {
this.sliders.push(slidesArr[i])
}
}
})
},
}
}
Smart猫小萌
相关分类