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輪播圖組件內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!