search
HomeWeChat AppletMini Program DevelopmentDetailed explanation of WeChat applet components: picker scroll selector

picker scroll selectorComponent description:

#picker:

Scroll selector, now supports three selectors, distinguished by the mode attribute ,

are the ordinary selector (mode = selector), time selector (mode = time), and date selector (mode = date),

The default is a normal selector.


picker rolling selector sample code runs as follows:



Detailed explanation of WeChat applet components: picker scroll selector

#The following is the WXML code

##

<view class="page">
  <view class="page__hd">
    <text class="page__title">picker</text>
    <text class="page__desc">选择器</text>
  </view>
  <view class="page__bd">
    <view class="section">
      <view class="section__title">地区选择器</view>
      <picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">
        <view class="picker">
          当前选择:{{array[index]}}
        </view>
      </picker>
    </view>
    <view class="section">
      <view class="section__title">时间选择器</view>
      <picker mode="time" value="{{time}}" start="09:01" end="21:01" bindchange="bindTimeChange">
        <view class="picker">
          当前选择: {{time}}
        </view>
      </picker>
    </view>
    <view class="section">
      <view class="section__title">日期选择器</view>
      <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange">
        <view class="picker">
          当前选择: {{date}}
        </view>
      </picker>
    </view>
  </view>
</view>

The following is the JS code

##

Page({
  data: {
    array: [&#39;中国&#39;, &#39;美国&#39;, &#39;巴西&#39;, &#39;日本&#39;],
    index: 0,
    date: &#39;2016-09-01&#39;,
    time: &#39;12:01&#39;
  },
  bindPickerChange: function(e) {
    console.log(&#39;picker发送选择改变,携带值为&#39;, e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  bindDateChange: function(e) {
    this.setData({
      date: e.detail.value
    })
  },
  bindTimeChange: function(e) {
    this.setData({
      time: e.detail.value
    })
  }
})

The following is the WXSS code

##

.page {
    min-height: 100%;
    flex: 1;
    background-color: #FBF9FE;
    font-size: 32rpx;
    font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
    overflow: hidden;
}
.page__hd{
    padding: 50rpx 50rpx 100rpx 50rpx;
    text-align: center;
}
.page__title{
    display: inline-block;
    padding: 20rpx 40rpx;
    font-size: 32rpx;
    color: #AAAAAA;
    border-bottom: 1px solid #CCCCCC;
}
.page__desc{
    display: none;
    margin-top: 20rpx;
    font-size: 26rpx;
    color: #BBBBBB;
}
.picker{
  padding: 26rpx;
  background-color: #FFFFFF;
}
.section{
    margin-bottom: 80rpx;
}
.section__title{
    margin-bottom: 16rpx;
    padding-left: 30rpx;
    padding-right: 30rpx;
}


Picker rolling selector’s
Main properties:

Normal selector (mode = selector)

Attribute nameArray[ ]When mode is selector, range is validvalueNumber0When mode is selector, it is a number, indicating which number in the range is selected, starting from 0. bindchangeEventHandle##Time selector: (mode = time)

Type

Default value

Description

##range

The change event is triggered when the value changes, event.detail = {value: value }

Attribute name

TypeDefault valueDescription represents the selected time, the format is "hh :mm” represents the beginning of the valid time range, the string format is” hh:mm” represents the end of the valid time range. The string format is "hh:mm"The change event is triggered when the value changes, event.detail = {value: value}

value

String

start
String

end
String

bindchange
EventHandle

Date picker: (mode = date)

valueString0 represents the selected date in the format of "YYYY-MM-DD" startString represents the start of the valid date range, the string format is "YYYY-MM-DD" endStringIndicates the end of the valid date range, the string format is "YYYY-MM-DD"fieldsStringdayValid values ​​are year, month, day, indicating the granularity of the selectorbindchangeEventHandleThe change event is triggered when the value changes, event.detail = {value: value}
##Attribute name

Type

Default value

Description




The above is the detailed content of Detailed explanation of WeChat applet components: picker scroll selector. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software