一开始的代码是这样子的,怎么调都无效:

<script>
  import BScroll from 'better-scroll'
    export default{
      name: "CityList",
      mounted(){
         this.scroll = new BScroll(this.$refs.wrapper);
        console.log(this.scroll);
      }
    }
</script>

最后的解决:

<script>
  import BScroll from 'better-scroll'
    export default{
      name: "CityList",
      mounted(){
         setTimeout(()=>{
           this.scroll = new BScroll(this.$refs.wrapper);
          },20)
      }
    }
</script>

转载自:https://www.e-learn.cn/content/qita/786075

Logo

前往低代码交流专区

更多推荐