vue + axios 跑马灯初始化加载数据的时候,默认没有显示图片
<el-carousel height="100%" class="height100 arrow-block arrow-button-bg" :autoplay="true"
arrow="always" indicator-position="none" :interval="interval" ref="carouselswiper2" initial-index="0">
<el-carousel-item v-for="list,index in swiper2" :key="index">
<div class="xczx_lsaq_qy height100">
<div class="xczx_lsaq_qy_img">
<img class="width100 height100" :src="list.img" />
</div>
</div>
</el-carousel-item>
</el-carousel>
<script>
export default {
data() {
return {
interval:5000,
swiper1: [],
}
},
created() {
this.get()
},
mounted() {
},
methods: {
get() {
let that = this
this.$http.post("api", {}, false).then((res) => {
this.$nextTick(() => {
that.swiper1 = res.rzlist
})
});
},
}
}
</script>
看上去没什么问题
结果什么都没有,郁闷了好多次了。。
最后发现里面必须要有一个默认值,来占位,然后Ctrl+F5 刷新就正常了。
swiper1: [
{
img: '',
lsItem: [{
icon: '',
label: '',
num: '',
unit: ''
},
{
icon: '',
label: '',
num: '',
unit: ''
},
{
icon: '',
label: '',
num: '',
unit: ''
},
]
}
]
:key="index" 不能重复哦