scroll-view 中scroll-top设置无效对问题

初次使用scroll-view 中scroll-top,结果发现没有效果,所以在网上搜了一下,发现有问题的人还挺多的,所以就在此说明一下

<scroll-view class="left-navbar" scroll-y="true">
      <view
        wx:for="{{list}}"
        class="{{ currentTab == index ? 'active' : '' }}"
        wx:key="unique"
        bindtap="{{ currentTab != index ? 'navbarTap':'' }}"
        id="{{index}}"
        data-screen-id="{{item.screenId}}"
        data-InsideId = "{{item.InsideId}}"
      >{{item.Name}}</view>
    </scroll-view>
    <!-- ---------------------------------------------------------------------------------------------------------------------- -->
    <scroll-view id="right" scroll-y="true" scroll-top="{{scrollTop}}">
      <!--商品展示-->
    <!-- <block wx:for="{{list}}" wx:key="index" > -->
      <view class="goods-list" wx:for="{{Childrenlist}}" wx:key="unique" wx:for-item="item2">
       
          <view class="goods-title">{{item2.Itself.Name}}</view>
          <view
            wx:for="{{item2.Children}}"
            class="goods"
            wx:key="unique"
            wx:for-item="item3"
            id="{{item.screenName}}"
            @tap="channeclick({{item3}})" data-movie="{{item.Itself}}" 
          >
            <image class="img" src="{{item.showImageUrl}}" wx:if="{{item.showImageUrl}}">
            <text>{{item3.Itself.Name}}</text>
          </view>
        </view>
       <!-- </block> -->
    </scroll-view>
    <script>
    data = {
    // 页面所需数据均需在这里声明,可用于模板数据绑定
    parameter: {
      navbar: '0',
      return: '1',
      title: '分类',
      color: true,
      class: '0',
      imgUrl: ''
    },
    currentTab: 0, //对应样式变化
    scrollTop: 0,
    navH: 0,
    windowWidth: 0,
    windowHeight: 0,
    screenId:0,
    list: [],
    tabbar:null,
    isshow:0,
    Childrenlist:[]
  };
   methods = {
      navbarTap: function (e) {
    var that = this;
      console.log(e,e.currentTarget.id)
      this.currentTab= e.currentTarget.id,   //按钮CSS变化
      this.screenId= e.currentTarget.dataset.screenid,
      this.scrollTop= this.scrollTop+0.01,   //切换导航后,控制右侧滚动视图回到顶部
      this.Childrenid  = e.currentTarget.dataset.insideid
      wx.setStorageSync("Childrenid",this.Childrenid)
      this.getChildrenlist()
    console.log(that.currentTab)
    console.log("###############")
	}
  },

注:this.scrollTop= this.scrollTop+0.01, 中的0.01可随便改,不建议改太大

你可能感兴趣的:(小程序,wepy,小问题)