当前位置:网站首页>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;
}边栏推荐
- uni-app获取当前页面路由url
- MySQL uses union all to count the total number of combinations of multiple tables and the number of tables respectively
- Calculus Learning
- 编程语言
- keras转tf.keras中VGG19 input_shape
- Macros, functions, and inline functions
- MYSQL虚拟列
- CDGA|交通行业做好数字化转型的核心是什么?
- Verilog 大小端以及 +:使用
- train_on_batch保存一下loss函数变化的图像
猜你喜欢

YOLO Nano:一种高度紧凑的只看一次的卷积神经网络用于目标检测

微信小程序分享页面,分享到朋友圈

什么是超融合?与传统架构有什么区别?.

ActiveMQ message component publish subscribe redelivery message redelivery

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

MT yolov6 training and testing

Let's make a summary

Picture format -webp

keras转tf.keras中VGG19 input_shape

2022 Season 6 perfect children's model Haikou competition area trial successfully concluded
随机推荐
Verilog 表达式
npm常用命令
laravel 8 实现 订单表按月份水平分表
一般乘法器设计,verilog code
“国防七校”之一西工大遭境外网络攻击
How is epoll encapsulated in golang?
手机开户一般哪个证券公司好?究竟网上开户是否安全么?
H5软键盘问题
MySQL的分库分表策略及应用场景
ServerApp.iopub
C# 语音端点检测(VAD)实现过程分析
JS获取图片或base64的宽高等基本信息
General multiplier design, verilog code
宏,函数和内联函数
什么是超融合?与传统架构有什么区别?.
train_on_batch保存一下loss函数变化的图像
Calculus Learning
uniapp微信小程序报错 TypeError: Cannot read property ‘call‘ of undefined
keras转tf.keras中VGG19 input_shape
mysql insert 时出现Deadlock死锁场景分析