zoukankan      html  css  js  c++  java
  • 微信小程序使用Swiper组件构建轮播图

    新建目录 posts (阅读页面)

    点击目录右键新建page

    目录结构如下:

    在app.json中,把posts调整为默认显示的页面(暂时先这样,具体的多页面之后再说)

    {
      "pages": [
        "pages/posts/posts",
        "pages/welcome/welcome"
        
      ],
      "window": {
        "navigationBarBackgroundColor": "#405f80"
      },
      "sitemapLocation": "sitemap.json"
    }

    官方文档里找到swiper组件

    posts.wxml

    <!--pages/posts/posts.wxml-->
    <view>
      <swiper indicator-dots="true" interval="2000" autoplay="true">
        <swiper-item><image src="/images/wx.png"></image></swiper-item>
        <swiper-item><image src="/images/vr.png"></image></swiper-item>
        <swiper-item><image src="/images/iqiyi.png"></image></swiper-item>
      </swiper>  
    </view>

    posts.wxss

    注意轮播图的尺寸取决于swiper容器的尺寸,而不是swiper-item的尺寸

    /* pages/posts/posts.wxss */
    swiper{
      width:100%;
      height:500rpx;
    }
    swiper image{
      width:100%;
      height:500rpx;
    }

    效果图:

  • 相关阅读:
    课后作业之找水王
    SCRUM第二阶段第十天
    第九周总结
    冲刺一3
    用户项目
    预会热词统计
    冲刺一2
    冲刺一(一阶)1
    第八周总结
    小组合作
  • 原文地址:https://www.cnblogs.com/chenyingying0/p/12553203.html
Copyright © 2011-2022 走看看