zoukankan      html  css  js  c++  java
  • 小程序多列选择器的使用

    记录是为了更好的成长!

    话不多说,直接上代码!

     1、页面

    <view class="section">
      <view class="section__title">多列选择器</view>
      <picker mode="selector" bindchange="bindPickerChange" value="{{index}}" range="{{array}}" range-key="{{'name'}}">
        <view class="picker">
          当前选择:{{array[index].name}}
        </view>
      </picker>
    </view>

    2、js

    Page({
    
      data: {
        array:[
          {
            name:'请选择类型'
          }
        ],
        index: 0,
        goods:{
          id:1,
          name:'电视机',
          type:'家电'
        }
      },
    
      onLoad: function (options) {
        var that = this
        wx.request({
          url: 'http://192.168.0.168:8090/findAllType',
          success: function (res) {
            that.setData({
              array: that.data.array.concat(res.data)
            })
            if (that.data.goods.type != '') {
              for (var i = 0; i < that.data.array.length; i++) {
                if (that.data.goods.type == that.data.array[i].name) {
                  that.setData({
                    index: i
                  })
                  break;
                }
              }
            }
          } 
        })
      },
      bindPickerChange:function(e){
        var that = this
        that.setData({
          index: e.detail.value
        })
      }
    
    })

    以上内容代表个人观点,仅供参考,不喜勿喷。。。

  • 相关阅读:
    六 . 爬虫 Xpath介绍和使用
    五. 爬虫 正则表达式
    四 . 爬虫 BeautifulSoup库参数和使用
    三 . 爬虫 url编码
    一 . 爬虫
    【HDU5952】Counting Cliques
    【HDU5521】Meeting
    【模板】回文自动机
    【CF1218E】Product Tuples
    【洛谷P2485】计算器
  • 原文地址:https://www.cnblogs.com/newbest/p/10822535.html
Copyright © 2011-2022 走看看