小程序事件
catchtap :点击不会冒泡
bindtap : 点击冒泡
data-ndnumType : 传递参数
e.currentTarget.dataset : 获取参数
<view class="tab_item" bindtap='toMyNode' data-current="1"> <view class="tab_item_top"> {{nodeOver}} </view> <view class="tab_item_bottom">已逾期</view> </view>
toMyNode: function(e){ var id = e.currentTarget.dataset.current wx.navigateTo({ url: '../myNode/myNode?id='+id }) }, wx.setStorageSync('index_node_refresh', true) : 本地存储 wx.getStorageSync('index_node_refresh') : 获取本地存储 wx.reLaunch({ url: '/pages/login/login' }) 退出登录 wx.redirectTo({ //同级页面跳转 url: '/pages/index/index' }) wx.switchTab({ url: '/pages/index/index' }) 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
// 获取滚动条当前位置--固定导航栏 <view class="task-table" id="task-table-box"> <view class="top flex {{fixedNav ? 'fixed-nav' : ''}}"> </view> </view> onPageScroll:function(e){ // 获取滚动条当前位置 wx.createSelectorQuery().select('#task-table-box').boundingClientRect( (rect) => { // console.log('rect',rect) if (rect.top <= 0) { //临界值,根据自己的需求来调整 this.setData({ fixedNav: true //是否固定导航栏 }) } else { this.setData({ fixedNav: false }) } }).exec() },