zoukankan      html  css  js  c++  java
  • 微信小程序入门 第一个页面搭建

    首先搭建首页

    微信小程序与web程序非常相似  有非常多的组件  多个组件形成一个页面 每个组件有自己一些特殊的属性来控制显示效果 通过js注册事件控制响应

    首先使用swiper实现一个banner轮播 实现点击banner跳转到指定的view

    <swiper indicator-dots="{{indicatorDots}}"
      autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
      <block wx:for="{{imgUrls}}">
        <swiper-item>
          <image bindtap='test'  data-url="pages/logs/logs" src="{{item}}" class="slide-image" width="100%" height="auto"/>
        </swiper-item>
      </block>
    
    </swiper>
    

      

    Page({
      data: {
        imgUrls: [
          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg',
        ],
        indicatorDots: false,
        autoplay: true,
        interval: 2000,
        duration: 1000
      },
     
      changeIndicatorDots: function(e) {
        this.setData({
          indicatorDots: !this.data.indicatorDots
        })
      },
      changeAutoplay: function(e) {
        this.setData({
          autoplay: !this.data.autoplay
        })
      },
      intervalChange: function(e) {
        this.setData({
          interval: e.detail.value
        })
      },
      durationChange: function(e) {
        this.setData({
          duration: e.detail.value
        })
      },
      test:function(e){
        var url=e.currentTarget.dataset.url;
        console.log(url);
            wx.switchTab(url);
    
      }
    })
    

      

    dataset

    在组件中可以定义数据,这些数据将会通过事件传递给 SERVICE。 书写方式: 以data-开头,多个单词由连字符-链接,不能有大写(大写会自动转成小写)如data-element-type,最终在 event.target.dataset 中会将连字符转成驼峰elementType

  • 相关阅读:
    Linux/windows查看设置环境变量指令
    转载:windows查看进程相关指令
    Ubuntu开启SSHD服务
    Ubuntu root方式登录
    洛谷P1466 集合 Subset Sums
    洛谷P1726 上白泽慧音
    洛谷P1983 车站分级
    洛谷P2577 [ZJOI2005]午餐
    洛谷P1119 灾后重建
    P1169 [ZJOI2007]棋盘制作
  • 原文地址:https://www.cnblogs.com/ProDoctor/p/6861119.html
Copyright © 2011-2022 走看看