微信小程序: scrollView滑動到指定位置


 scroll.wxml:

<scroll-view class="banner" scroll-y scroll-into-view="{{cur}}" scroll-with-animation>
    <view class='item' id="one">1</view>
    <view class='item' id="two">2</view>
    <view class='item' id="three">3</view>
    <view class='item' id="four">4</view>
    <view class='item' id="five">5</view>
</scroll-view> 
<scroll-view class="point" scroll-x>
  <view class="item1" id="one" bindtap="scrollView">one</view>
  <view class="item1" id="two" bindtap="scrollView">two</view>
  <view class="item1" id="three" bindtap="scrollView">three</view>
  <view class="item1" id="four" bindtap="scrollView">four</view>
  <view class="item1" id="five" bindtap="scrollView">five</view>
</scroll-view>

scroll.js:

Page({
  data: {
    cur:"one" , //當前滾動的位置
  },
  scrollView(e){
    console.log(e);
    this.setData({
      cur: e.target.id,
    })
  },
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM