• 小程序Tap切换


    <!-- Tap切换 -->
      <view class="nav_title">
        <view class="nav_tab">
          <view wx:for="{{list}}" class="{{selected==index?'hidden':'show'}}" wx:key="this" data-index='{{index}}' bindtap="selected">
            {{item}}
            <view class="{{selected==index?'nav_underline':''}}"></view>
          </view>
        </view>
    
        <!-- tab框显示内容 -->
        <view wx:if="{{selected == 0}}">aaa</view>
        <view wx:if="{{selected == 1}}">bbb</view>
        <view wx:if="{{selected == 2}}">ccc</view>
        <view wx:if="{{selected == 3}}">ddd</view>
      </view>
    Page({
    
      /**
       * 页面的初始数据
       */
      data: {
        selected: 0,
        list: ['上衣', '裤子', '套装', '女鞋'],
        
      },
      
    
     
      selected: function (e) {
        console.log(e)
        let that = this
        let index = e.currentTarget.dataset.index
        console.log(index)
        if (index == 0) {
          that.setData({
            selected: 0
          })
        } else if (index == 1) {
          that.setData({
            selected: 1
          })
        } else if (index == 2) {
          that.setData({
            selected: 2
          })
        } else {
          that.setData({
            selected: 3
          })
        }
      },
      /**
       * 生命周期函数--监听页面加载
       */
      onLoad: function (options) {
      
      },
    
      /**
       * 生命周期函数--监听页面初次渲染完成
       */
      onReady: function () {
    
      },
    
      /**
       * 生命周期函数--监听页面显示
       */
      onShow: function () {
    
      },
    
      /**
       * 生命周期函数--监听页面隐藏
       */
      onHide: function () {
    
      },
    
      /**
       * 生命周期函数--监听页面卸载
       */
      onUnload: function () {
    
      },
      //向下滑动
      onPageScroll: function () {
    
      },
      /**
       * 页面相关事件处理函数--监听用户下拉动作
       */
      onPullDownRefresh: function () {
    
      },
    
      /**
       * 页面上拉触底事件的处理函数
       */
      onReachBottom: function () {
    
      },
    
      /**
       * 用户点击右上角分享
       */
      onShareAppMessage: function () {
    
      }
    })
  • 相关阅读:
    pandas
    简单的图片滑动&标签页的前进后退
    xpath 语法&元素交互操作&选项卡操作
    Selenium请求库-day5下午
    初始python
    异步多线程下载网页爬取的视频
    python学习-day4上午
    爬虫初试
    爬虫
    内置模块--又称为常用模块
  • 原文地址:https://www.cnblogs.com/520yh/p/12373393.html
Copyright © 2020-2023  润新知