当前位置:网站首页>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;
}边栏推荐
猜你喜欢

工厂模式和策略模式的区别

keras转tf.keras中VGG19 input_shape

Cdga | what is the core of digital transformation in the transportation industry?

Enrollment brochure for system integration project management engineer certification in July 2022

Core development board & debugger

Handwriting Redux thunk

Abstract classes and interfaces

Product manager certification enrollment brochure (NPDP) in July 2022

How is epoll encapsulated in golang?

2022年7月产品经理认证招生简章(NPDP)
随机推荐
手机开户一般哪个证券公司好?究竟网上开户是否安全么?
基于区域注意的通用目标检测
Calculus Learning
闭关修炼(二十五)基础web安全
首次触电,原来你是这样的龙蜥社区 | 龙蜥开发者说第8期
【目标检测】|指标 A probabilistic challenge for object detection
Handwriting Redux thunk
使用GPU训练kernel切换
MySQL uses union all to count the total number of combinations of multiple tables and the number of tables respectively
JS获取图片或base64的宽高等基本信息
训练查看(问题暂存)
来个小总结吧
Verilog shift operator
Mysql使用union all统计多张表组合总数,并分别统计各表数量
Verilog 表达式
Verilog 大小端以及 +:使用
PointNet/Pointnet++训练及测试
NPM common commands
Did you really make things clear when you were promoted or reported?
专业结构record