非常簡單好用實(shí)用的輪播圖swiper banner組件


非常簡單好用實(shí)用的輪播圖swiper banner組件; 下載完整代碼請?jiān)L問uni-app插件市場地址:https://ext.dcloud.net.cn/plugin?id=12786


效果圖如下:


實(shí)現(xiàn)代碼如下:

# 非常簡單好用實(shí)用的輪播圖swiper banner組件,一行代碼即可實(shí)現(xiàn)輪播圖

#### 使用方法

```使用方法

<!-- interval:輪播間隔時(shí)間? imgList: 輪播圖數(shù)組? @click:輪播圖點(diǎn)擊事件-->

<ccCarouseView interval="2000" :imgList="myImgList" @click="goImgClick"></ccCarouseView>

```

#### HTML代碼部分

```html

<template>

<view class="content">

<view class="text-area">

<text class="title">{{title}}</text>

</view>

<!-- interval:輪播間隔時(shí)間? imgList: 輪播圖數(shù)組? @click:輪播圖點(diǎn)擊事件-->

<ccCarouseView interval="2000" :imgList="myImgList" @click="goImgClick"></ccCarouseView>

</view>

</template>

```

#### JS代碼 (引入組件 填充數(shù)據(jù))

```javascript

<script>

import ccCarouseView from '../../components/ccCarouseView.vue'

export default {

components: {

ccCarouseView

},

data() {

return {

title: '使用方法: <ccCarouseView interval="2000" :imgList="myImgList" @click="goImgClick"></ccCarouseView>',

myImgList: []

}

},

onLoad() {

// 模擬數(shù)據(jù)

this.myImgList = [{

'name': '圖片1',

'imgUrl': 'https://cdn.pixabay.com/photo/2016/08/15/14/33/rock-towers-1595571_1280.jpg'

},

{

'name': '圖片2',

'imgUrl': 'https://cdn.pixabay.com/photo/2023/05/07/12/14/beetle-7976249_1280.jpg',

},

{

'name': '圖片3',

'imgUrl': 'https://cdn.pixabay.com/photo/2019/12/19/16/48/canton-4706569_1280.jpg',

},

{

'name': '圖片4',

'imgUrl': 'https://cdn.pixabay.com/photo/2022/04/27/12/30/switzerland-7160290_1280.jpg'

}

]

},

methods: {

goImgClick(item){

? uni.showModal({

? title:'溫馨提示',

content: '點(diǎn)擊圖片帶的數(shù)據(jù)= ' + JSON.stringify(item)

? })

}

}

}

</script>

```

#### CSS

```CSS

<style>

.content {

display: flex;

flex-direction: column;

align-items: center;

justify-content: center;

}

.text-area {

display: flex;

justify-content: center;

margin: 20px 0px;

width: calc(100vw - 40px);

}

.title {

font-size: 32rpx;

color: #161616;

}

</style>

```

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容