vue swiper动态添加轮播图bodydiv id=vue_list v-cloakdiv class=bg1div class=swiper-container banner mar1div class=swiper-wrapperdiv class=swiper-slide v-for=(item, index) in caro...
vue swiper动态添加轮播图
<body>
<div id="vue_list" v-cloak>
<div class="bg1">
<div class="swiper-container banner mar1">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item, index) in carouselList"><a :href="item.url"><img
:src="item.previewPath"/></a></div>
</div>
<div class="swiper-pagination"></div>
</div>
</div>
</div>
</body>
<script>
vm_list = new Vue({
el: '#vue_list',
data: {
carouselList: [],
},
created() {
this.getCarouselList()
},
methods: {
getCarouselList() {
let that = this
ajaxJson(ctx + 'api/carousel/list').done(function (res) {
that.carouselList = res.data.carouselList
that.$nextTick(() => {
new Swiper('.swiper-container', {
autoplay: true,
})
})
})
},
}
})
</script>
沃梦达教程
本文标题为:vue swiper动态添加轮播图
猜你喜欢
- 深入浅析AjaxFileUpload实现单个文件的 Ajax 文件上传库 2022-12-15
- javascript 判断当前浏览器版本并判断ie版本 2023-08-08
- jsPlumb+vue创建字段映射关系 2023-10-08
- ajax实现输入提示效果 2023-02-14
- vue keep-alive 2023-10-08
- JS实现左侧菜单工具栏 2022-08-31
- 1 Vue - 简介 2023-10-08
- 关于 html:如何从 css 表中删除边距和填充 2022-09-21
- 基于CORS实现WebApi Ajax 跨域请求解决方法 2023-02-14
- layui数据表格以及传数据方式 2022-12-13