1***@qq.com
1***@qq.com
  • 发布:2018-06-04 14:18
  • 更新:2018-06-26 10:59
  • 阅读:2829

【报Bug】hbuilder 将 react项目打包成APP时 react-router失效

分类:HBuilder

详细问题描述
[内容]
hbuilder打包react生成的dist目录的文件 但是router无法跳转,或者失效,而同样为单页面应用的vue 则没有这个现象。
重现步骤
[步骤] react项目, webpack打包出dist生产文件, hbuilder打包APP
[结果] 生成后的APP 打开后路由有问题
[期望] 生成后的APP 页面正常跳转 项目正常运行

运行环境 windows
[系统版本]
[浏览器版本]
[IDE版本]
[mui版本]

附件
[代码片段]
[安装包]

联系方式
[QQ]
[电话]

2018-06-04 14:18 负责人:无 分享
已邀请:
7***@qq.com

7***@qq.com

看一下你的路由模式,有些模式本地不能使用

1***@qq.com

1***@qq.com (作者)

<Provider store={store}>  
        <BrowserRouter >  
          <Switch>  
            <Route exact path='/' component={Home} />  
            <Route path='/list' component={List} />  
            <Route path='/category' component={Category} />  
            <Route path='/user' component={User} />  
            <Route path='/cart' component={Cart} />  
            <Route path='/search' component={Search} />  
            <Route path='/detail/:id' component={Detail}/>  
            {/* <Route path='*' component={NotFound} /> */}  
          </Switch>  
        </BrowserRouter>  
      </Provider>

这是路由配置,不过我大概知道问题原因了。

猫爱水煮鱼

猫爱水煮鱼 - 号客服哈市的废话

请问解决了吗?我也遇到了同样的问题,在webpack的服务器8080端口开发调试好好的,本地80端口只能打开主页,其他路径都是报错的
[an error occurred while processing this directive] The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. [an error occurred while processing this directive]
这是页面报错信息
下面是控制台报错信息
Error in event handler for (unknown): TypeError: Cannot read property 'textContent' of null
at displayError (chrome-extension://chklaanhfefbnpoihckbnefhakgolnmc/content.js:4:99)
at chrome-extension://chklaanhfefbnpoihckbnefhakgolnmc/content.js:282:4

该问题目前已经被锁定, 无法添加新回复