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:

到此這篇關(guān)于uniapp vue與nvue輪播圖 輪播圖組件的文章就介紹到這了,更多相關(guān)uniapp輪播圖組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關(guān)文章
Vue3+NodeJS+Soket.io實現(xiàn)實時聊天的示例代碼
本文主要介紹了Vue3+NodeJS+Soket.io實現(xiàn)實時聊天的示例代碼,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-01-01
vue-cli構(gòu)建的項目如何手動添加eslint配置
這篇文章主要介紹了vue-cli構(gòu)建的項目如何手動添加eslint配置,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-04-04
Vue+OpenLayers?創(chuàng)建地圖并顯示鼠標所在經(jīng)緯度(完整代碼)
這篇文章主要介紹了Vue+OpenLayers?創(chuàng)建地圖并顯示鼠標所在經(jīng)緯度,本文使用的是高德地圖,結(jié)合實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-11-11
vue 3.x 中mixin封裝公用方法應(yīng)用方式
這篇文章主要介紹了vue 3.x 中mixin封裝公用方法應(yīng)用方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-05-05

