• 小程序实现选项卡效果代码


    //test.wxml
    <
    view class='h_ctr4 bc_white'> <view bindtap='xuan' data-num="1" data-id='zuijin' class="{{_num == 1 ? 'isxuan':'xuan'}}">全部</view> <view bindtap='xuan' data-num="2" data-id='zuigao' class="{{_num == 2 ? 'isxuan':'xuan'}}">未使用</view> <view bindtap='xuan' data-num="3" data-id='quanbu' class="{{_num == 3 ? 'isxuan':'xuan'}}">已使用</view> </view>
    //test.wxss
    /*
    选项卡*/ .h_ctr4 { width: 100%; height: 75rpx; line-height: 75rpx; font-size: 30rpx; margin-top: 0rpx; display: flex; } .xuan{ width: 250rpx; text-align: center; color: #333333; } .isxuan{ text-align: center; width: 250rpx; border-bottom: 10rpx solid #b4282d; color: #b4282d; }
    //test.js
    Page({
    /** * 页面的初始数据 */ data: { _num: 1, //这是点击选项卡参数,不是接口不需要传值 }, //点击切换距离、销量、全部店铺 xuan: function (e) { var that = this; this.setData({ _num: e.target.dataset.num }) var id = e.currentTarget.dataset.id; if (id == "zuijin") { wx.request({ // url: 'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json', // url: 'http://192.168.199.181/a/gongsi_zuijin.json', url: rootDocment + '/a/gongsi_zuijin.json', data: { id: id }, method: 'POST', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } if (id == "zuigao") { wx.request({ // url: 'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json', // url: 'http://192.168.199.181/a/gongsi_zuijin.json', url: rootDocment + '/a/gongsi_zuigao.json', data: { id: id }, method: 'POST', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } if (id == "quanbu") { wx.request({ // url: 'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json', // url: 'http://192.168.199.181/a/gongsi_zuijin.json', url: rootDocment + '/a/gongsi_quanbu.json', data: { id: id }, method: 'POST', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } }, })
  • 相关阅读:
    字符串的长度 -- js
    导入drupal中文语言包
    ubuntu修改iP地址
    人生需要苦难和敌人
    Drupal.theme未解之谜
    如何定义带下标的js数组
    smtp admin email 似乎可以考虑在
    js中的apply 和 call
    js 点号 中括号
    代码调试
  • 原文地址:https://www.cnblogs.com/shark1100913/p/8491676.html
Copyright © 2020-2023  润新知