小程序模板网

xiaochun系列教程--微信小程序 Picker & rich-text

2018-04-21 抢时间

城市选择器 region

//index.wxml
<picker mode="region" bindchange="bindRegionChange" value="{{region}}">
  <view class="picker">
    当前选择:{{region[0]}},{{region[1]}},{{region[2]}}
  view>
picker>

//index.js
data: {
    region: ['广东省', '广州市', '海珠区']
}
  •  

 

// Picker.wxml


<picker mode="multiSelector" value="{{index}}" bindcolumnchange="bindPickerChange" range="{{province}}" range-key="{{'name'}}">
  <view class="picker">
    当前选择:{{province[0][0].name}}{{province[1][0].name}}
  view>
picker>
  •  

// Picker.js


// picker.js
var cityObj = require("../../utils/city")
Page({
  data: {
    index: 0
  },
  onLoad: function (options) {
    var defaultCitys = cityObj.getCitysById("0")
    this.setData({
      province: [cityObj.provinceList, defaultCitys]
    })
  },
  bindPickerChange(e) {
    if (e.detail.column == 0) {
      var citys = cityObj.getCitysById(e.detail.value);
      this.setData({
        province: [cityObj.provinceList, citys]
      })
    }
  }
})
  •  

时间选择器 time


<picker mode="time" value="{{time}}" start="09:01" end="21:01" bindchange="bindTimeChange">
  <view class="picker">
    当前选择: {{time}}
  view>
picker>


<picker mode="date" value="{{time}}" start="2015-09-01" end="2017-09-01" fields="month" bindchange="bindTimeChange">
  <view class="picker">
    当前选择: {{time}}
  view>
picker>
  •  


易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/23857.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询