当前位置:网站首页>Wechat applet project: tab navigation bar
Wechat applet project: tab navigation bar
2022-06-29 09:14:00 【Duanmucheng】
Here are two kinds of code , At the beginning, it is the second kind of ( Use variables to control wx:if) Later, I found a more convenient method (“tabBar”)
see : https://www.cnblogs.com/min-min-min/p/7452880.html
https://www.cnblogs.com/qinlinkun/p/12881811.html
https://blog.csdn.net/runner_123/article/details/80434119
Method 1 :
effect 
Add to app.json Inside ,pagePath Customize the page to switch to
"tabBar": {
"color": "#fff",
"selectedColor": "#fff",
"backgroundColor": "#31c27c",
"position": "top",
"list": [
{
"pagePath": "pages/index/index",
"text": " recommend "
},
{
"pagePath": "pages/index/index2",
"text": " Ranking List "
},
{
"pagePath": "pages/index/index3",
"text": " Search for "
}
]
},Method 2 :
effect :
Code :
.js
data: {
navbar:[' recommend ',' Find out '],
currentTab:2,
},
// Respond by clicking on the navigation bar
navbarTap:function(e){
var that=this;
that.setData({
currentTab:e.currentTarget.dataset.idx,
TypeItem:that.data.navbar[that.data.currentTab]
})
},.wxml
<!--pages/subject/subject.wxml-->
<!-- Navigation menu -->
<view class="navbar" style="z-index:50">
<!-- loop -->
<view wx:for="{
{navbar}}" data-idx="{
{index}}" wx:key="unique" class="item {
{currentTab==index ? 'active' : ''}}" bindtap="navbarTap">
<view class="notice" wx:if="{
{count[index]>0}}">{
{
count[index]}}</view>
{
{
item}}
<!--<text bindtap="navbarTap">{
{
item}}</text>-->
</view>
</view>
<!-- recommend Words id What is it -->
<view hidden="{
{currentTab !== 0}}" id="two">
<template is="list" data="{
{maintainRecordlist}}" />
<view>
recommend
</view>
</view>
<!-- Find out -->
<view hidden="{
{currentTab !== 1}}" id="one">
<template is="list" data="{
{maintainRecordlist}}" />
<view class="products">
Find out
Hot column
</view>
<view class="classify">
classification
</view>
</view>
.wcss
/* pages/subject/subject.wxss */
/* Dot numeric callout */
.notice {
width:28rpx;
height:28rpx;
color:#fff;
text-align:center;
background-color:#ec9e14;
border-radius:50%;
position:absolute;
float:left;
/* margin-top: 8rpx;*/
top:5rpx;
font-size: 15rpx;
right:30rpx;
line-height:30rpx; }
/* Top navigation style */
.navbar{
flex: none;
display: flex;
background: #ffffff;
margin-top: 20rpx;
z-index: 50;
}
.navbar .item{
position: relative;
flex: auto;
text-align: center;
line-height: 100rpx;
font-size: 35rpx;
color: #666666;
font-family: Microsoft YaHei;
}
.navbar .item.active{
color: #ec9e14;
font-size: 35rpx;
font-family: Microsoft YaHei;
border: none;
}
.navbar .item.active:after{
border: none;
content: "";
display: block;
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 4rpx;
font-size: 24rpx;
color: #666666;
font-family: Microsoft YaHei;
}
.products{
position: fixed;
top: 120rpx;
bottom: 450rpx;
left: 0;
width: 100%;
height: calc(100% - 500rpx);
border: #666666;
border-style: solid;
}
.classify{
position: fixed;
top:840rpx ;
bottom: 0;
left: 0;
width: 100%;
border: #ec9e14;
border-style: solid;
}边栏推荐
- promise方法的简单使用
- Backpack Lecture 9 - detailed understanding and code implementation
- 微信小程序跳转公众号图文内容
- cokkie和session的区别
- uniapp微信小程序报错 TypeError: Cannot read property ‘call‘ of undefined
- MYSQL虚拟列
- Macros, functions, and inline functions
- Using scan in redistemplate
- How is epoll encapsulated in golang?
- 闭关修炼(二十一)Servlet生命周期、service方法源码分析、线程安全问题
猜你喜欢

keras转tf.keras中VGG19 input_shape

微信小程序判断url的文件格式

查找字符串中重复次数最多的元素

今年的网络安全“体检”你做了吗?

打印服务IP设置方案

Calculus Learning

MySQL uses union all to count the total number of combinations of multiple tables and the number of tables respectively

【To .NET】C#数据模型,从Entity Framework Core到LINQ

AugFPN:改进多尺度特征学习用于目标检测

Cdga | what is the core of digital transformation in the transportation industry?
随机推荐
Did you really make things clear when you were promoted or reported?
Using scan in redistemplate
Verilog size and +: Using
PAT (Basic Level) Practice (中文)1003 我要通过! (20分) C语言实现
单例模式的理解
Verilog 拼接操作符号
记一些笔试题
调试H5页面-weinre及spy-debugger真机调试
工厂模式和策略模式的区别
手写 redux-thunk
npm常用命令
记微信小程序分享代码片段
Activemq消息组件发布订阅ReDelivery消息重新投递
微信小程序自定义多项选择器
笔试题“将版本号从大到小排列”
微信小程序子组件向页面传值(父子组件间的通信)带源码
递归方法 rbac菜单层级显示 无限极分类
微积分学习
2022年7月系统集成项目管理工程师认证招生简章
闭关修炼(二十一)Servlet生命周期、service方法源码分析、线程安全问题