Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customRoutes一个页面配多个路径,部分路径definePageConfig不生效 #15989

Closed
forgivenoom opened this issue Jun 26, 2024 · 1 comment

Comments

@forgivenoom
Copy link

相关平台

H5

浏览器版本: 随意
使用框架: React

复现步骤

官方demo
添加h5自定义路由配置 比如

      router: {
        mode: "browser",
        customRoutes: {
          "pages/index/index": [
            "/index",
            "/home",
            "/home-app",
            "pages/index/index",
          ],
        },
      },

访问 /home/home-app 路径均无法获取到pageConfig, definePageConfig中配置不生效

期望结果

正常生效

实际结果

不生效

环境信息

Taro CLI 3.6.9 environment info:
    System:
      OS: macOS 14.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
      Yarn: 1.22.22 - /opt/homebrew/bin/yarn
      npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.9 => 3.6.9
      @tarojs/components: 3.6.9 => 3.6.9
      @tarojs/helper: 3.6.9 => 3.6.9
      @tarojs/plugin-framework-react: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-alipay: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-h5: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-jd: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-qq: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-swan: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-tt: 3.6.9 => 3.6.9
      @tarojs/plugin-platform-weapp: 3.6.9 => 3.6.9
      @tarojs/runtime: 3.6.9 => 3.6.9
      @tarojs/shared: 3.6.9 => 3.6.9
      @tarojs/taro: 3.6.9 => 3.6.9
      @tarojs/taro-loader: 3.6.9 => 3.6.9
      @tarojs/webpack5-runner: 3.6.9 => 3.6.9
      babel-preset-taro: 3.6.9 => 3.6.9
      eslint-config-taro: 3.6.9 => 3.6.9

补充信息

get pageConfig() {
        const routePath = addLeadingSlash(stripBasename(this.pathname, this.basename));
        const homePage = addLeadingSlash(this.homePage);
        return this.routes.find((r)=>{
            var _a;
            const pagePath = addLeadingSlash(r.path);
            return [
                pagePath,
                homePage
            ].includes(routePath) || ((_a = routesAlias.getConfig(pagePath)) === null || _a === void 0 ? void 0 : _a.includes(routePath));
        });
    }

这里routesAlias.getConfig应该用routePath去查配置

@forgivenoom
Copy link
Author

forgivenoom commented Jun 26, 2024

#15725 已经修复了

This was referenced Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant