el-carousel 初始化不加载数据

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"  不能重复哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值