mpvue开发微信小程序锚点滚动城市列表 引用scroll-view (代码全)

先上效果图:

mpvue开发微信小程序锚点滚动城市列表 引用scroll-view (代码全)_第1张图片

引用微信小程序官方的 scroll-view 组件 https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html

mpvue开发微信小程序锚点滚动城市列表 引用scroll-view (代码全)_第2张图片

主要通过更改:scroll-into-view="toView"的内容  很方便就 写出效果  记着加scroll-with-animation 就有动画过渡的效果!

分字母城市列表 LetterCity 链接:https://pan.baidu.com/s/126kgYEIBPwc8z-UgKcV4GQ  提取码:wt8u

主要代码(文章下面有全部代码):



export default {
  data () {
    return {
      thatnum: 0,//选择字母变颜色
      toView:'',//选中的字母
    }
  },    
  methods: {
    
    //选择字母
    addClassName: function(index,id) {
      this.thatnum = index;
      var that=this;
      for (let i = 0; i < that.LetterCity.length; ++i) {
        if (that.LetterCity[i].letter == id) {
          that.toView= that.LetterCity[i].letter
          break
        }
      }
    },
    
  }
}


完整代码:






 

你可能感兴趣的:(微信小程序,mpvue,MpVue,微信小程序)