美文网首页
uniapp微信小程序swiper 轮播图

uniapp微信小程序swiper 轮播图

作者: jing_bao | 来源:发表于2023-09-25 11:29 被阅读0次

uni-swiper-dot 为轮播图指示点组件
swiper设置圆角,需要为swiper组件设置如下样式:

 //设置圆角
  overflow: hidden;
  border-radius: 4px;
  transform: translateY(0);

示例
template

<template>
  <view class="card-box">
    <uni-swiper-dot
      class="uni-swiper-dot-box"
      :info="swiperList"
      :current="current"
      :dots-styles="dotsStyles"
      mode="round"
      field="content"
      @click-item="clickItem"
    >
      <swiper
        class="swiper"
        :current="swiperDotIndex"
        style="height: 140px"
        :autoplay="true"
        :interval="interval"
        :circular="true"
        @change="onChangeSwiper"
      >
        <swiper-item v-for="item in swiperList" :key="item.id">
          <image class="swiper-image" :src="item.url" mode="aspectFill" @click="enlargeImg(item)" />
        </swiper-item>
      </swiper>
    </uni-swiper-dot>id
  </view>
</template>

script


<script lang="ts" setup>
import { ref, watch } from 'vue'

const swiperList = [
  {
    id: 1,
    url: 'https://img0.baidu.com/it/u=3021883569,1259262591&fm=253&fmt=auto&app=120&f=JPEG?w=1140&h=641'
  },
  {
    id: 2,
    url: 'https://img0.baidu.com/it/u=3021883569,1259262591&fm=253&fmt=auto&app=120&f=JPEG?w=1140&h=641'
  },
  {
    id: 3,
    url: 'https://img0.baidu.com/it/u=3021883569,1259262591&fm=253&fmt=auto&app=120&f=JPEG?w=1140&h=641'
  },
  {
    id: 4,
    url: 'https://img0.baidu.com/it/u=3021883569,1259262591&fm=253&fmt=auto&app=120&f=JPEG?w=1140&h=641'
  },
  {
    id: 5,
    url: 'https://img0.baidu.com/it/u=3021883569,1259262591&fm=253&fmt=auto&app=120&f=JPEG?w=1140&h=641'
  }
]
const interval = 3000
const current = ref(0)
const swiperDotIndex = ref(0)
const dotsStyles = ref({
  width: 3,
  height: 3,
  backgroundColor: 'rgb(255,255,255,0.6)',
  border: 'none',
  color: '#fff',
  selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  selectedBorder: 'none'
})
const clickItem = (e: any) => {
  swiperDotIndex.value = e
}
const onChangeSwiper = (e: any) => {
  current.value = e.detail.current
}
const enlargeImg = (item: any) => {
  //点击事件
}
</script>


样式

<style scoped lang="scss">
.card-box {
  width: 100%;
  height: 100%;
}

.swiper {
  height: 100%;
 //设置圆角
  overflow: hidden;
  border-radius: 4px;
  transform: translateY(0);
}

.swiper-image {
  width: 100%;
  height: 100%;
}
</style>

样式效果图


image.png

相关文章

  • 小程序轮播图

    | 微信小程序轮播图实现,实现在首页上轮播图,让效果更好看。查看微信小程序开发文档可知,微信小程序提供swiper...

  • 五分钟掌握微信小程序轮播图

    微信小程序轮播图实现,比Android 轮播图来说,显得轻松多了。微信小程序提供swiper组件,官网api提供的...

  • 微信小程序学习-轮播图组件swiper

    轮播图组件swiper 微信小程序提供了滑块视图容器swiper,可以便捷实现轮播图效果。 这个名字和移动端常用的...

  • 微信小程序轮播图

    微信小程序 swiper组件轮播图 照着开发文档尝试,总是能有所收获.之前做Android开发,做个轮播图并不简单...

  • 微信小程序实现类3D轮播图

    在写微信小程序时,有写到实现3D轮播图的效果,可以直接使用微信小程序中自带的组件swiper来实现 效果图如下: ...

  • 微信小程序swiper轮播图

    在微信小程序中我们经常需要展示一些图片,或者一些数据(公告)用来循环展示。微信为我们封装了一个组件可以让我们用来方...

  • 微信小程序------轮播图

    swiper 微信小程序实现轮播图,和网站,APP的效果差不多,代码少,效率高。 先来看看效果图: 主要用swip...

  • 微信小程序 旋转木马/缩放轮播图 功能

    文章涉及技术点 微信小程序原生Swiper控件 Wxss Transform、Transition 轮播条滚动回调...

  • 微信小程序swiper轮播图高度

    小程序中的轮播图很简单,官方都有例子的,但是唯一的缺陷就是swiper是固定死的150px高度,这样如果传入的图片...

  • 微信小程序(二) 轮播图

    小程序提供了swiper来供我们使用轮播图。效果图: 首先先看home.wxml: swiper 的属性可见官网,...

网友评论

      本文标题:uniapp微信小程序swiper 轮播图

      本文链接:https://www.haomeiwen.com/subject/yoaqbdtx.html