vue.js - 没报错,但是该显示的组件没有显示(element-plus)
<div class="content">
<el-carousel :interval="4000" type="card" height="200px">
<el-carousel-item v-for="(item,index) in seamlessImgs" :key="index">
<img :src="item" >
</el-carousel-item>
</el-carousel>
</div>
const seamlessImgs = [
'https://img.alicdn.com/imgextra/i2/3969049197/O1CN01K9f7b82HoHaBhSrvK_!!3969049197.png',
'https://img.alicdn.com/imgextra/i1/3969049197/O1CN01mM8wzf2HoHa9qRJil_!!3969049197.png',
'https://img.alicdn.com/imgextra/i1/3969049197/O1CN015Mbl9R2HoHaEPwkSX_!!3969049197.png',
'https://img.alicdn.com/imgextra/i1/3969049197/O1CN013phiLI2HoHaC7jIHl_!!3969049197.png',
'https://img.alicdn.com/imgextra/i2/3969049197/O1CN019yJAF22HoHaCqDzGS_!!3969049197.png',
'https://img.alicdn.com/imgextra/i2/3969049197/O1CN01z7GiFh2HoHaF6Z5sU_!!3969049197.png',
'https://img.alicdn.com/imgextra/i3/3969049197/O1CN0110t1DJ2HoHaEDm9ZS_!!3969049197.png',
'https://img.alicdn.com/imgextra/i1/3969049197/O1CN01AFvUaX2HoHa9qU4Dq_!!3969049197.png',
'https://img.alicdn.com/imgextra/i4/3969049197/O1CN01pFCKOQ2HoHa8dwjWh_!!3969049197.png'
]
return { seamlessImgs }
控制台也没报错,在后台看是这个模块是空的没有元素
原因是你使用
<img :src="item" >
,并没有设置宽高,然后<img>
默认截取了图片左上角为内容展示,而轮播图里的图片上下都是灰色了,给了你内容为空的错觉。可以使用其他风景图,就可看到内容,比如:https://q5.itc.cn/q_70/images03/20240324/eec25140bcd54427a96c...问题出在轮播图的图片不符合导致的。