<!--index.wxml-->
<view class="container">
<view class="navtap" >
<a data-current="{{setting.current.key}}" bindtap="clickcurrent" style="color:{{currentSelect.key == 'current'?mainColor:oldcolor}};">
<text>本期试用</text>
<text class="activeline" style="background-color:{{currentSelect.key == 'current'?mainColor:whiteColor}};"></text>
</a>
<a data-current="{{setting.trailer.key}}" bindtap="clickcurrent" style="color:{{currentSelect.key == 'trailer'?mainColor:oldcolor}};">
<text>即将上线</text>
<text class="activeline" style="background-color:{{currentSelect.key == 'trailer'?mainColor:whiteColor}};"></text>
</a>
<a data-current="{{setting.report.key}}" bindtap="clickcurrent" style="color:{{currentSelect.key == 'report'?mainColor:oldcolor}};">
<text>试用报告</text>
<text class="activeline" style="background-color:{{currentSelect.key == 'report'?mainColor:whiteColor}};"></text>
</a>
<a data-current="{{setting.mytry.key}}" bindtap="clickcurrent" style="color:{{currentSelect.key == 'mytry'?mainColor:oldcolor}};">
<text>我的试用</text>
<text class="activeline" style="background-color:{{currentSelect.key == 'mytry'?mainColor:whiteColor}};"></text>
</a>
</view>
<block wx:if="{{currentSelect.key == 'current'}}"> </block>
<block wx:if="{{currentSelect.key == 'trailer'}}"> </block>
<block wx:if="{{currentSelect.key == 'report'}}"> </block>
<block wx:if="{{currentSelect.key == 'mytry'}}"> </block>
</view>

js

//index.js
//获取应用实例
const app = getApp() Page({
data: {
motto: '首页',
setting: {
current: {
key: "current",
},
trailer: {
key: "trailer"
},
report: {
key: "report"
},
mytry: {
key: "mytry"
}
},
mainColor: '#91d8d2',
oldcolor: 'grey'
},
currentSelect: {},
onLoad: function () {
this.setData({
'currentSelect.key': 'current'
})
},
clickcurrent: function (event) {
var that = this
that.setData({
'currentSelect.key':event.currentTarget.dataset.current
})
}
})

wxss

/**index.wxss**/

.navtap{
width:%;
height:40px;
text-align:center;
display:flex;
font-size:15px;
color:#;
background-color:#fff; } .navtap a{
flex:;
color:#;
line-height:38px;
} .activeline{
width:26px;
height:2px;
background-color:#fff;
display:block;
margin: auto;
}
.navtap a {
flex:;
color:#;
line-height:38px;
}

小程序tab切换代码的更多相关文章

  1. 微信小程序tab切换,可滑动切换,导航栏跟随滚动实现

    简介 看到今日头条小程序页面可以滑动切换,而且tab导航条也会跟着滚动,点击tab导航,页面滑动,切导航栏也会跟着滚动,就想着要怎么实现这个功能 像商城类商品类目如果做成左右滑动切换类目用户体验应该会 ...

  2. 根据id来实现小程序tab切换,

    本例根据绑定id来实现tab切换,但本例仍有缺陷,用for循环数据,无法实现切换.如有大神能够有更好方法,欢迎留言更正 WXML: <view class="tab"> ...

  3. 小程序tab切换 点击左右滑动

    wxml <scroll-view scroll-x="true" class="navbar-box"> <block wx:for=&qu ...

  4. 小程序——Tab切换

    <view class="body"> <view class="nav bc_white"> <view class=" ...

  5. 微信小程序Tab选项卡切换大集合

    代码地址如下:http://www.demodashi.com/demo/14028.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...

  6. PHP小程序后端支付代码亲测可用

    小程序后端支付代码亲测可用 <?php namespace Home\Controller; use Think\Controller; class WechatpayController ex ...

  7. 小程序TAB列表切换内容动态变化,scrollview高度根据内容动态获取

    滑动tab选项卡 一.在小程序里面tab选项卡是用的是自带的swiper组件,下面直接上代码 <view class="container"> <view cla ...

  8. 微信小程序tab(swiper)切换

    <- wxml -> <view class="youhui"> <view ' bindtap='toggle'> 未使用 </view ...

  9. 微信小程序开发---各代码文件简介

    根据上一文,已建立QuickStart 项目,该项目系本人毕设部分内容,所以记录以便以后查阅 开发小程序就必须了解小程序项目目录结构和文件作用,接下来就根据我现在自学得到的知识把这些记录下来. 一.目 ...

随机推荐

  1. 解决Maven 编译出的jar中没有主清单属性

    出现这个问题的原因是 pom 中没有添加主程序入口 在配置中添加如下配置 <plugin> <groupId>org.apache.maven.plugins</grou ...

  2. pc端vue 滚动到底部翻页

    html: <div class="list" ref="scrollTopList"> <div class="listsmall ...

  3. arm的基本介绍

    2440是arm9核,是基于v4 架构 6410是arm11核 基于v6架构 210是a8的核   基于v7架构 前面的是经典阵营,比较老.Arm11之后改为contex系列. Arm7的水准和M3相 ...

  4. [LeetCode] 76. 最小覆盖子串 ☆☆☆☆☆(滑动窗口)

    https://leetcode-cn.com/problems/minimum-window-substring/solution/hua-dong-chuang-kou-suan-fa-tong- ...

  5. 采集代理ip 地址【西刺,快代理】

    # 嗯,...因为经常需要使用代理去抓一点东西,就有了下面一段代码,第一版不是很好,后面用到了再来优化 import re,pymysql,time,redis from urllib.request ...

  6. c# 方法的隐藏

  7. 前端自己导出Excel

    1.导出当前页面,这是最简单的,只是导出当前页面的数据. exportData(tableid, name) { let table; let uri = 'data:application/vnd. ...

  8. 第一周助教小结——发布作业&线上答疑

    第一周助教小结 助教博客:https://www.cnblogs.com/jason5689/ 本周点评数目:0份 由于发布的作业还未截至,第一次的作业点评还没开始进行,就描述一下评论博客前的感受吧 ...

  9. Lorenzo Von Matterhorn(map的用法)

    http://www.cnblogs.com/a2985812043/p/7224574.html 解法:这是网上看到的 因为要计算u->v的权值之和,我们可以把权值放在v中,由于题目中给定的u ...

  10. archlinux 使用 postgresql

    一.安装与初始化 1.初始化数据目录 默认安装后已创建 postgres 系统用户 切换到 postgres 用户 $ sudo -iu postgres # Or su - postgres for ...