uniapp vue与nvue轮播图之轮播图组件的示例代码
更新时间:2021年12月29日 15:32:08 作者:Abdulaziz02
这篇文章主要介绍了uniapp vue与nvue轮播图轮播图组件的实例代码,代码简单易懂,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
vue部分如下:
<template> <view class=""> <!-- 轮播图组件 --> <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular=""> <block v-for="(item,index) in swipers" :key="index"> <swiper-item> <view class="swiper-item" @tap="event(index)"> <image :src="item.src" lazy-load style="height: 350upx;"></image> </view> </swiper-item> </block> </swiper> </view> </template>
nvue部分如下:
<template> <div> <!-- 轮播图组件 --> <slider :auto-play="true" :interval="3000" class="slider"> <div style="position: relatice;" v-for="(item,index) in swipers" :key="index" @click="event(index)"> <image class="image" resize="cover" :src="item.src"></image> </div> <indicator class="indicator"></indicator> </slider> </div> </template>
nvue部分的css样式如下:
<style> .slider,.image{ width: 750px; height: 350px; } .indicator{ position: absolute; right: 0; bottom: 0; width: 150px; height: 30px; background-color: rgba(0,0,0,0); item-color:rgba(255,255,255,0.5); item-selected-color: #FFFFFF; } </style>
js部分如下:
vue与nvue的js写法是一样的
<script> export default { data() { return { swipers:[{src:"/static/images/demo/demo4.png"}, {src:"/static/images/demo/demo4.png"}, {src:"/static/images/demo/demo4.png"}, {src:"/static/images/demo/demo4.png"}] } }, methods: { event(index){ console.log("点击了 index:"+index) } } } </script>
效果图如下:
vue:
nvue:
到此这篇关于uniapp vue与nvue轮播图 轮播图组件的文章就介绍到这了,更多相关uniapp轮播图组件内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
相关文章
vue中的this.$router.push()路由传值方式
这篇文章主要介绍了vue中的this.$router.push()路由传值方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2023-10-10Vue生命周期activated之返回上一页不重新请求数据操作
这篇文章主要介绍了Vue生命周期activated之返回上一页不重新请求数据操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-07-07Vue中watch、computed、updated三者的区别及用法
这篇文章主要介绍了Vue中watch、computed、updated三者的区别及用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-07-07
最新评论