新手开发 微信小程序 跳转失效问题

2024-09-06 21:18:02 浏览数 (1)

情况1 : 页面跳转

三种跳转

wx.redirectTo

wx.navigateTo

wx.switchTab (想不清楚这玩意存在的意思,不了解其低层设计)

tabBar.list中使用 wx.switchTab 跳转到目标页面。

非tabBar.list,页面中跳转用wx.redirectTo 或者 wx.navigateTo

wx.redirectTo 跳转后,左上角有 home 主页按钮(home页非entryPagePath, home页是 pages[0])

wx.navigateTo 跳转后,左上角有 < 返回按钮

如app.json配置示例:

代码语言:txt复制
{
  "pages": [
    "pages/home/home",
    "pages/index/index",
    "pages/logs/logs",
    "pages/reward/reward",
    "pages/user/login/login",
    "pages/user/profile/profile",
    "pages/posts/posts",
    "pages/product/detail/detail",
    "pages/product/list/list"
    
  ],
  "entryPagePath": "pages/home/home",
  "usingComponents": {},
  "useExtendedLib": {
    "kbone": true,
    "weui": true
  },
  "window": {
    "navigationBarBackgroundColor": "#ffffff",
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "ka10000小程序",
    "backgroundColor": "#eeeeee",
    "backgroundTextStyle": "light"
  },
  "style": "v2",
  "componentFramework": "glass-easel",
  "sitemapLocation": "sitemap.json",
  "lazyCodeLoading": "requiredComponents",
  "tabBar": {
    "list": [
      {
        "pagePath": "pages/home/home",
        "text": "首页",
        "iconPath": "assets/images/home.png",
        "selectedIconPath": "assets/images/home-selected.png"
      },
      {
        "pagePath": "pages/posts/posts",
        "text": "列表",
        "iconPath": "assets/images/list.png",
        "selectedIconPath": "assets/images/list-selected.png"
      },
      {
        "pagePath": "pages/user/profile/profile",
        "text": "个人中心",
        "iconPath": "assets/images/customer-center.png",
        "selectedIconPath": "assets/images/customer-center-selected.png"
      }
    ]
  }
}

0 人点赞