zoukankan      html  css  js  c++  java
  • 微信小程序之Swiper组件

    一、概述

    滑块视图容器。其中只可放置swiper-item组件,否则会导致未定义的行为。

    官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html

    二、Swiper实现引导页

    在移动开发中,我们经常使用ViewPager(Android)和UIScrollView(ios)来实现引导页面,效果如下。

    test.wxml

    <swiper indicator-active-color='#fff' indicator-dots="true" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}"
      interval="{{interval}}" duration="{{duration}}">
      <block wx:for="{{imgs}}" wx:for-index="index" wx:key="swiperItem" wx:for-item="item">
        <swiper-item class="swiper-items">
          <image class="swiper-image" src="{{item}}"></image>
          <button class="button-img" bindtap="start" wx:if="{{index == imgs.length - 1}}">立即体验</button>
        </swiper-item>
      </block>
    </swiper>
    View Code

    test.wxss

    swiper {
      position: absolute;
      height: 100%;
       100%;
    }
    
    .swiper-image {
      height: 100%;
       100%;
      opacity:0.9;
    }
    
    .button-img{   
       position: relative;
       bottom: 120px;
       height: 40px;
        120px;
       opacity:0.6;
    }
    View Code

    test.js

    Page({
      data: {
        imgs: [
          "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2522069454.jpg",
          "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2522778567.jpg",
          "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2523516430.jpg",
        ],
    
        img: "http://img.kaiyanapp.com/7ff70fb62f596267ea863e1acb4fa484.jpeg",
        duration: 2000, // 滑动动画时长
        indicatorDots: true, // 是否显示指示点
        autoplay: true, // 是否自动切换
        interval: 3000, // 自动切换时间间隔
      },
      start: function () {
        wx.showToast({
          title: '该功能未上线!',
          icon: 'none',
          duration: 1500
        })
      },
    })
    View Code

    当点击"立即体验",会有一个弹窗提示。

    本文参考链接:

    https://blog.csdn.net/xiangzhihong8/article/details/80645094

  • 相关阅读:
    树莓派搭建NAS之Seaflile
    Samba配置不同用户组不同用户的访问权限
    Samba-Linux权限理解
    Samba 共享配置
    服务端主动给客户端推送消息
    drf 权限认证
    drf-jwt分页器详解
    drf-jwt的过滤,筛选,排序,分页组件
    jwt token认证
    jwt
  • 原文地址:https://www.cnblogs.com/xiao987334176/p/14818742.html
Copyright © 2011-2022 走看看