原因:走马灯组件必须在数据渲染完毕后挂载
解决方法:使用v-if
<template>
<el-carousel
:interval="4000"
type="card"
height="200px"
:autoplay="false"
v-if="bannerList[0]" //确保数据渲染完毕
>
<el-carousel-item v-for="(item, index) in bannerList" :key="index">
<img
text="2xl"
justify="center"
:src="item.imageUrl"
style="width: 100%; height: 100%"
/>
</el-carousel-item>
</el-carousel>
</template>