vue中如何让el-carousel-item字符串滚动
时间: 2023-05-23 15:01:17 浏览: 136
你可以使用vue-awesome-swiper插件,并设置滚动效果。具体实现可以参考以下代码片段:
```
<template>
<div id="app">
<swiper :options="swiperOption">
<swiper-slide>
<el-carousel :interval="4000">
<el-carousel-item v-for="(item, index) in list" :key="index">
<div class="item-content">{{ item }}</div>
</el-carousel-item>
</el-carousel>
</swiper-slide>
</swiper>
</div>
</template>
<script>
import 'swiper/css/swiper.css';
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
name: 'app',
components: {
swiper,
swiperSlide
},
data () {
return {
swiperOption: {
autoplay: true,
loop: true,
pagination: {
el: '.swiper-pagination'
}
},
list: ['滚动1', '滚动2', '滚动3']
}
}
}
</script>
<style scoped>
.item-content {
width: 100%;
height: 20px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
```
阅读全文