微信小程序 不同角色进入不同页面、呈现不同底部导航栏

遇到这个需求之前一直使用的小程序默认底部导航栏,且小程序默认入口页面为pages/index/index,要使不同角色呈现不同底部导航栏,必须要在不同页面引用不同的自定义导航栏。本篇将结合分包(subPackages)展开以下三步叙述。

一、创建不同角色的页面

1、目录中创建分包personA、personB。

2、app.json补充分包配置。

二、创建不同角色的底部导航栏

1、在conponents目录下创建personA和personB的自定义导航栏组件。

2、填充导航栏内容。

html 复制代码
<!--components/tabBarA/tabBarA.wxml-->
<view class="bottom-fixed">
    <text>A的底部导航栏</text>
</view>

/* components/tabBarA/tabBarA.wxss */
.bottom-fixed{
    width: 100%;
    height: 200rpx; 
    position: fixed;
    bottom: 0;
    background-color: antiquewhite;
}
html 复制代码
<!--components/tabBarB/tabBarB.wxml-->
<view class="bottom-fixed">
    <text>B的底部导航栏</text>
</view>

/* components/tabBarB/tabBarB.wxss */
.bottom-fixed{
    width: 100%;
    height: 200rpx;
    position: fixed;
    bottom: 0;
    background-color:azure;
}

三、完善页面内容

1、完善pages/index/index页面,控制跳转到personA或者personB的页面。

javascript 复制代码
// index.js
Page({
    onShow(option){
        wx.reLaunch({
          url: '/personA/index/index',
        //   url: '/personB/index/index',
        })
    }
})

2、 完善personA的页面

html 复制代码
<!--personA/index/index.wxml-->
<text>personA的页面</text>

<tabBar></tabBar>


<!--personA/index/index.json-->
{
    "usingComponents": {
        "tabBar": "/components/tabBarA/tabBarA"
    }
}

3、完善personB的页面

html 复制代码
<!--personB/index/index.wxml-->
<text>personB的页面</text>

<tabBar></tabBar>


<!--personB/index/index.json-->
{
    "usingComponents": {
        "tabBar": "/components/tabBarB/tabBarB"
    }
}

完结。

相关推荐
CRMEB定制开发4 小时前
CRMEB会员电商系统集群部署 + 腾讯云日志托管优化方案
微信小程序·公众号商城·商城源码·crmeb·开源商城
weixin_177297220696 小时前
短剧小程序系统开发:技术驱动下的内容创新之路
小程序·语音交友
老华带你飞6 小时前
健身管理|基于java的健身管理系统小程序(源码+数据库+文档)
java·数据库·小程序·vue·论文·毕设·健身管理系统小程序
2501_916008896 小时前
iOS混淆工具有哪些?在集成第三方 SDK 时的混淆策略与工具建议
android·ios·小程序·https·uni-app·iphone·webview
weixin_177297220696 小时前
盲盒抽卡机小程序系统开发:打造个性化娱乐新平台
小程序·娱乐
个人看法7 小时前
小程序中,给一段富文本字符串文案特殊内容加样式监听点击事件
小程序
2501_915921437 小时前
Windows 如何上架 iOS 应用?签名上传全流程 + 工具推荐
android·ios·小程序·https·uni-app·iphone·webview
说私域10 小时前
企业通讯与营销技术融合创新:定制开发开源AI智能名片S2B2C商城小程序的协同价值研究
人工智能·小程序·开源
2501_9160074711 小时前
iOS 文件管理实战指南 查看 App 数据与系统日志的完整方法
android·ios·小程序·https·uni-app·iphone·webview
2501_9151063213 小时前
iOS 内测上架流程详解:跨平台团队如何快速部署 TestFlight
android·ios·小程序·https·uni-app·iphone·webview