zoukankan      html  css  js  c++  java
  • 微信小程序-scroll-view组件

    <view class="section">
      <view class="section__title">vertical scroll</view>
      <scroll-view scroll-y style="height: 200px;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
        <view id="green" class="scroll-view-item bc_green"></view>
        <view id="red"  class="scroll-view-item bc_red"></view>
        <view id="yellow" class="scroll-view-item bc_yellow"></view>
        <view id="blue" class="scroll-view-item bc_blue"></view>
      </scroll-view>
    
      <view class="btn-area">
        <button size="mini" bindtap="tap">click me to scroll into view </button>
        <button size="mini" bindtap="tapMove">click me to scroll</button>
      </view>
    </view>
    <view class="section section_gap">
      <view class="section__title">horizontal scroll</view>
      <scroll-view class="scroll-view_H" scroll-x style="">
        <view id="green" class="scroll-view-item_H bc_green"></view>
        <view id="red"  class="scroll-view-item_H bc_red"></view>
        <view id="yellow" class="scroll-view-item_H bc_yellow"></view>
        <view id="blue" class="scroll-view-item_H bc_blue"></view>
      </scroll-view>
    </view>
    index.wxml
    .scroll-view-item{width:100%; height: 100px;}
    
    .scroll-view_H{line-height: 100px;height: 100px;width: 100%;white-space:nowrap;}
    .scroll-view-item_H{width:50%; height: 100px;display: inline-block;}
    
    .bc_green {background: green;}
    .bc_red {background: red;}
    .bc_blue {background: blue;}
    .bc_yellow{background: yellow;}
    indexwxss
    var order = ['red', 'yellow', 'blue', 'green', 'red']
    Page({
      data: {
        toView: 'red',
        scrollTop: 100
      },
      upper: function (e) {
        console.log(e)
      },
      lower: function (e) {
        console.log(e)
      },
      scroll: function (e) {
        console.log(e)
      },
      tap: function (e) {
        for (var i = 0; i < order.length; ++i) {
          if (order[i] === this.data.toView) {
            this.setData({
              toView: order[i + 1]
            })
            break
          }
        }
      },
      tapMove: function (e) {
        this.setData({
          scrollTop: this.data.scrollTop + 10
        })
      }
    })
    index.js
    {
      "pages":[
        "index/index"
      ],
      "window":{
        "backgroundTextStyle":"light",
        "navigationBarBackgroundColor": "#fff",
        "navigationBarTitleText": "WeChat",
        "navigationBarTextStyle":"black"
      }
    }
    app.json
    {
        "description": "项目配置文件。",
        "packOptions": {
            "ignore": []
        },
        "setting": {
            "urlCheck": true,
            "es6": true,
            "postcss": true,
            "minified": true,
            "newFeature": true
        },
        "compileType": "miniprogram",
        "libVersion": "1.9.98",
        "appid": "wxc32558e56ff41f5d",
        "projectname": "scroll-view%E7%BB%84%E4%BB%B6",
        "isGameTourist": false,
        "condition": {
            "search": {
                "current": -1,
                "list": []
            },
            "conversation": {
                "current": -1,
                "list": []
            },
            "game": {
                "currentL": -1,
                "list": []
            },
            "miniprogram": {
                "current": -1,
                "list": []
            }
        }
    }
    project.config.json

  • 相关阅读:
    MySQL数据库to_char() to_date()
    爬虫的基本要求和考核标准
    打印MySQL操作错误
    暖通施工时遇到大梁不需要打洞,开小孔的三通时无需放样
    CAD 图纸上的实体的扩展数据不能记数据库中的ID 因为数据库数据删除时,ID也被删除,这样就找不到该实体的信息了
    关于定时关机的命令 shutdown s t 30 at 12:00 shutdown s
    下次坐飞机时,我要揣个弹弓进去, 因为我要去完成我小时候想完成而没能完成的梦想
    CAD 块与块相交,交点在块的边界上,不在块内的某实体上
    豆奶粉干吃好吃
    CAD 我们用弧度时 不要去定义Pi是多少,用Math.Pi
  • 原文地址:https://www.cnblogs.com/zhyue93/p/wechat-scroll-view.html
Copyright © 2011-2022 走看看