微信小程序 scroll-view滚动到索引位置

微信小程序 scroll-view滚动到索引位置_第1张图片

 

  
    
      
    {{item.wordindex}}  
      
      
        
          
        
      
    
  
  
    
    {{item.wordindex}}  
    
  
// pages/order/car/add_car/car_brand/car_brand.js  
var app = getApp()  
Page({  
  data: {  
    "brandList": [],  
    "wordindex": [],  
    "toView": '#',  
  
  },  
  onLoad: function (options) {  
    var that = this;  
    // 页面初始化 options为页面跳转所带来的参数  
    app.func.req('getCarBrand?cx=1', function (res) {  
      if (res.data.result == 'false') {  
        console.log('false');  
        that.wetoast.toast({  
          title: res.data.msg,  
          duration: 2000  
        })  
      } else {  
        that.setData({  
          brandList: res.data.brandList,  
          wordindex: res.data.brandList,  
        });  
        var cData = that.data.brandList;  
        cData[0].wordindex = "#";//先修改json值  
        that.setData({ //再set值  
          wordindex: cData  
        })  
      }  
    }, function (res) {  
  
    });  
  
  },  
  onReady: function () {  
    // 页面渲染完成  
  },  
  onShow: function () {  
    // 页面显示  
  },  
  onHide: function () {  
    // 页面隐藏  
  },  
  onUnload: function () {  
    // 页面关闭  
  },  
  click: function () {  
    wx.navigateTo({  
      url: '/pages/order/car/add_car/car_model/car_model',  
    })  
  },  
  choiceWordindex: function (event) {  
    let wordindex = event.currentTarget.dataset.wordindex;  
    if (wordindex == '#') {  
      this.setData({  
        toView: '常用品牌',  
      })  
    } else {  
      this.setData({  
        toView: wordindex,  
      })  
    }  
  
    console.log(this.data.toView);  
  }  
})  

 

你可能感兴趣的:(小程序)