【问题标题】:react-hot-loader not working properly with all urlsreact-hot-loader 无法与所有 url 正常工作
【发布时间】:2018-03-31 15:35:25
【问题描述】:

我已经设法通过 react-hot-loader 进行了基本设置。它适用于任何带有单个/(如localhost:8080/test)的url,但是一旦我添加另一个斜杠(例如localhost:8080/test/asd),它就会刷新,而不是正确的热更新。页面仍然显示正常,只是热加载部分不如预期。

这是我的设置:https://github.com/severisv/react-hot-loader-example

发生了什么事?有没有办法解决这个问题?

【问题讨论】:

  • 我认为你应该使用 react 路由器。

标签: reactjs typescript webpack react-hot-loader


【解决方案1】:

将 publicPath 添加到 webpack-config 的输出部分解决了这个问题:

output: {
    ...
    publicPath: '/'
},

【讨论】:

    猜你喜欢
    • 2017-11-03
    • 2020-06-08
    • 2016-08-20
    • 2016-02-28
    • 2018-02-11
    • 1970-01-01
    • 2018-03-02
    • 2018-01-15
    • 2021-11-06
    相关资源
    最近更新 更多