当前位置:网站首页>WeChat applet picker scroll selector use detailed explanation
WeChat applet picker scroll selector use detailed explanation
2022-07-30 16:55:00 【snail on motorcycle】
Basic use of picker
The picker scroll selector (hereinafter referred to as picker) is a component that comes with the WeChat applet. It does not need to introduce any files. Just put the picker code in the appropriate position and click the scroll selector that can pop up from the bottom.
Easiest to use 
Of course I have no data defined, so there is no content in the selector.
picker assignment
How to assign a value to the scroll selector above?Use range to add selections to the scroll selector.
range assignment 
Of course, data can also be bound, but it should be noted that the data can only be an array in the format of ["1","2","3"].

Multi-column picker selector
The scroll selector above has only one column. Sometimes we need two or more columns. How to use it?
Use mode = multiSelector to define it as a multi-column selector.If not set, it defaults to a normal selector, and others:
Time picker: mode = time
Date picker: mode=date
Province and city selector: mode = region, here is a multi-column selector.
Multi-column scroll selector After setting it as a multi-column selector, you need to specify several columns through the data. If you also use the above test data, we can see that there are three columns in the selector. The reason is that there are three groups of test data, that is, throughThe length of the array determines how many columns of selectors there are.

If we need to do two columns, the data will be divided into two groups, and the data in each group will be the data of the column.As shown:

Simply put, multi-column picker is to control several columns and column data through range data.If you want to make three columns, make three sets of data, and four columns make four sets of data...

data: {
test: [
["The first in the first column", "The second in the first column", "The third in the first column"],//The first column of data
["The first in the second column","The second in the second column"],//The second column of data
["Third column"],
["The fourth column"]//If you need to do a few columns, do a few sets of data
]
},
picker event listener
After the picker scroll selector is made, its operation events should be monitored. There are two main operation events, bindchange (change value event, understood as pointIt can be triggered after confirming the button) and bindcolumnchange (list change event, understood as a sliding trigger event, this event is only valid in multi-column selectors), here ITest these two events using a multi-column selector as an example:

bindchange event: When the event is executed after clicking OK, you can find the output value of each column through the console outputWhich column is selected.The e.detail.value value is the row selected for each column.I have selected the first row here so the value is [0,0,0,0].

bindcolumnchange event: When we slide a column of data in the selector, this event will be triggered.Viewing in Taichung, it will show which column has been swiped and which column has been swiped to.

Here I changed the console output event, and you can see it more carefully through the animation below.

Define the selection of the sliding selector
Sometimes we need to make a default selection for the scroll selector. At this time, the selection state of each column can be set by value.As in the above four columns, if I want to set the second value by default, I can set [1,1,1,1] for the value.

Summary: Through the above introduction, we can understand that configuring picker is mainly to configure its content, default value, and two events.However, it should be noted that the value of picker is not the value we need in practical applications, so we often need to make another data to correspond to this side.
边栏推荐
- leetcode:1488. 避免洪水泛滥【二分 + 贪心】
- huato hot update environment construction (DLL method hot update C# code)
- 基于STM32F407使用ADC采集电压实验
- 如何注册域名、备案以及解析
- 如何在 UE4 中用代码去控制角色移动
- Scheduling_Channel_Access_Based_on_Target_Wake_Time_Mechanism_in_802.11ax_WLANs
- 3D激光SLAM:LeGO-LOAM论文解读---激光雷达里程计与建图
- 服务器装好系统的电脑怎么分区
- 向量检索基础方法总结
- DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
猜你喜欢

LeetCode167: Sum of two numbers in sorted array

Explore CSAPP Experiment 2-bomb lab-Section 1

MySql统计函数COUNT详解

FP6606CMP5 CPC-16L USB类型-C和PD充电控制器 百盛电子代理商

论文阅读 (63):Get To The Point: Summarization with Pointer-Generator Networks

【SOC】Classic output hello world

你是这样的volatile,出乎意料

MySQL超详细安装教程 手把手教你安装MySQL到使用MySQL 最简单的MySQL安装方式,这种方式装,卸载也简单

@Bean注解详解

理解实现搜索二叉树
随机推荐
Discuz magazine/news report template (jeavi_line) UTF8-GBK template
PHP message feedback management system source code
登录模块调试-软件调试入门
云厂商做生态需要“真连接、真赋能”,用“技术+真金实银”发展伙伴
torch.optim.Adam() function usage
华为云数据治理生产线DataArts,让“数据‘慧’说话”
大厂面试官眼中的好简历到底长啥样
.NET 6.0中使用Identity框架实现JWT身份认证与授权
测试管理与规范
Horizontal Pod Autoscaler(HPA)
bert-base调试心得
数据库的三大范式
[Geek Challenge 2020] Roamphp1-Welcome
Gvim order record
哎,这要人老命的缓存一致问题啊
data storage
理解实现搜索二叉树
每日一题:两数之和
向量检索基础方法总结
DLCM - 基于列表上下文信息的重排序模型