|
|
首页代码:
- // 动态设置tabBar第一项
- // #ifdef APP || WEB
- let tabIndex = getApp().globalData.tabIndex;
- console.log(tabIndex)
- if (tabIndex != 0) {
- // #ifdef APP || WEB
- let tabBar = {
- index: 0,
- selectedIconPath: "/static/tabbar/default.png",
- text: ''
- }
- // #endif
- // #ifdef MP
- let tabBar = {
- index: 0,
- text: '首页',
- iconPath: "/static/tabbar/home.png",
- selectedIconPath: "/static/tabbar/home-selected.png",
- }
- // #endif
- uni.setTabBarItem(tabBar)
- getApp().globalData.tabIndex = 0;
- }
- // #endif
复制代码 分类页代码:
- onLoad() {
- // 动态设置tabBar第一项
- // uni.setTabBarItem({
- // index: 0,
- // text: '首页',
- // iconPath: "/static/tabbar/home.png",
- // selectedIconPath: "/static/tabbar/home-selected.png",
- // })
- },
- onShow() {
- // 动态设置tabBar第一项
- // #ifdef APP || WEB
- let tabIndex = getApp().globalData.tabIndex;
- console.log(tabIndex)
- if (tabIndex == 0) {
- let tabBar = {
- index: 0,
- text: '首页',
- iconPath: "/static/tabbar/home.png"
- }
- uni.setTabBarItem(tabBar)
- }
- getApp().globalData.tabIndex = 1;
- // #endif
-
- },
复制代码 订单页代码:
- onShow() {
- // 动态设置tabBar第一项
- // #ifdef APP || WEB
- let tabIndex = getApp().globalData.tabIndex;
- console.log(tabIndex)
- if (tabIndex == 0) {
- let tabBar = {
- index: 0,
- text: '首页',
- iconPath: "/static/tabbar/home.png"
- }
- uni.setTabBarItem(tabBar)
- }
- getApp().globalData.tabIndex = 2;
- // #endif
-
- },
复制代码 我的页面代码:
- onShow() {
- // 动态设置tabBar第一项
- // #ifdef APP || WEB
- let tabIndex = getApp().globalData.tabIndex;
- console.log(tabIndex)
- if (tabIndex == 0) {
- let tabBar = {
- index: 0,
- text: '首页',
- iconPath: "/static/tabbar/home.png"
- }
- uni.setTabBarItem(tabBar)
- }
- getApp().globalData.tabIndex = 3;
- // #endif
-
- },
复制代码
|
|