The use of range-key, a multi-column selector in WeChat applet

不言
Release: 2018-06-27 10:33:34
Original
1939 people have browsed it

This article mainly introduces in detail how to use the range-key of the multi-column selector of the WeChat applet. It has a certain reference value. Interested friends can refer to it.

The example of this article is We have shared the specific code of the WeChat applet multi-column selector for your reference. The specific content is as follows

<picker mode="multiSelector" bindchange="bindMultiPickerChange2" bindcolumnchange="bindMultiPickerColumnChange2" value="{{multiIndex}}" range="{{objectMultiArray}}" range-key="{{&#39;name&#39;}}">
 <view class="picker">
  当前选择:{{objectMultiArray[0][multiIndex2[0]].name}},{{objectMultiArray[1][multiIndex2[1]].name}}
 </view>
</picker>
Copy after login

Page({

 /**
 * 页面的初始数据
 */
 data: {
 objectMultiArray: [
  [
  {
   id: 0,
   name: &#39;无脊柱动物&#39;
  },
  {
   id: 1,
   name: &#39;脊柱动物&#39;
  }
  ], [
  {
   id: 0,
   name: &#39;扁性动物&#39;
  },
  {
   id: 1,
   name: &#39;线形动物&#39;
  },
  {
   id: 2,
   name: &#39;环节动物&#39;
  },
  {
   id: 3,
   name: &#39;软体动物&#39;
  },
  {
   id: 3,
   name: &#39;节肢动物&#39;
  }
  ]
 ],
 multiIndex2: [0, 0],
 },


 bindMultiPickerChange2: function (e) {
 console.log(&#39;picker发送选择改变,携带值为&#39;, e.detail.value)
 this.setData({
  multiIndex2: e.detail.value
 })
 },
 bindMultiPickerColumnChange2: function (e) {
 console.log(&#39;修改的列为&#39;, e.detail.column, &#39;,值为&#39;, e.detail.value);
 var data = {
  objectMultiArray: this.data.objectMultiArray,
  multiIndex2: this.data.multiIndex2
 };
 data.multiIndex2[e.detail.column] = e.detail.value;
 switch (e.detail.column) {
  case 0:
  switch (data.multiIndex2[0]) {
   case 0:
   data.objectMultiArray[1] = [
    { id: 0, name: &#39;扁性动物&#39; },
    { id: 1, name: &#39;线形动物&#39; },
    { id: 2, name: &#39;环节动物&#39; },
    { id: 3, name: &#39;软体动物&#39; },
    { id: 3, name: &#39;节肢动物&#39; }
   ];
   // data.multiArray[2] = [&#39;猪肉绦虫&#39;, &#39;吸血虫&#39;];
   break;
   case 1:
   data.objectMultiArray[1] = [
    { id: 0, name: &#39;鱼&#39; },
    { id: 1, name: &#39;线形两栖动物&#39; },
    { id: 2, name: &#39;爬行动物&#39; }
   ];
   break;
  }
  data.multiIndex2[1] = 0;
  // data.multiIndex[2] = 0;
  break;
 }
 this.setData(data);
 }


})
Copy after login

Please remember to like it! ! !

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to UI and container components in WeChat Mini Programs

Three-level linkage selection for WeChat Mini Programs How to use the tool

Introduction to global configuration of WeChat applet development

The above is the detailed content of The use of range-key, a multi-column selector in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!