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动态添加轮播图
基础教程推荐
猜你喜欢
- 使用ajax跨域调用springboot框架的api传输文件 2023-02-23
- 关于Ajax跨域问题及解决方案详析 2023-02-23
- Javascript Bootstrap的网格系统,导航栏和轮播详解 2023-08-11
- HTML clearfix清除浮动讲解 2022-11-20
- cocos creator游戏实现loading加载页面,游戏启动加载动画 2022-10-29
- 在实战中可能碰到的几种ajax请求方法详解 2023-02-01
- Ajax发送和接收请求 2022-12-15
- Ajax+smarty技术实现无刷新分页 2022-12-15
- uniapp开发微信小程序自定义顶部导航栏功能实例 2022-10-21
- JS滚动到顶部踩坑解决记录 2023-07-10