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輪播圖組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關文章
vue中的this.$router.push()路由傳值方式
這篇文章主要介紹了vue中的this.$router.push()路由傳值方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-10-10Vue生命周期activated之返回上一頁不重新請求數(shù)據(jù)操作
這篇文章主要介紹了Vue生命周期activated之返回上一頁不重新請求數(shù)據(jù)操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07Vue中watch、computed、updated三者的區(qū)別及用法
這篇文章主要介紹了Vue中watch、computed、updated三者的區(qū)別及用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07