【发布时间】:2016-08-23 17:21:00
【问题描述】:
我以为我开始了解 React Router,但是在添加一个为其组件加载 css 的库时,我遇到了新问题。从我家导航到包含该组件的页面时一切正常,但是当我刷新它时,字体的 url 被破坏了......
我找到了一些指针 here 和 here 但到目前为止还没有运气。这是一个常见问题吗?如何解决它?
我使用 webpack 开发服务器,默认配置由 yeoman scaffolder 构建。
我使用的库是React Fa来显示图标。
当我在http://localhost:8000/ 上加载我的应用程序时,一切正常,然后我导航到http://localhost:8000/customer/ABCD1234/chat,我的图标就正常了。字体已正确加载。
然后我刷新页面,我在控制台看到:
DOMLazyTree.js?019b:56 GET http://localhost:8000/customer/ABCD1234/assets/926c93d201fe51c8f351e858468980c3.woff2
这显然是坏的,因为客户部分不应该在这里......
到目前为止,这是我的路由器:
ReactDOM.render(
<Router history={browserHistory}>
<Route path='/' component={App}>
<IndexRoute component={Index}/>
<Route path='customer/:id' component={Customer} />
<Route path='customer/:id/chat' component={CustomerChat}/>
<Route path="*" component={ NotFound } />
</Route>
</Router>
, document.getElementById('support-app'));
我还尝试在我的 index.html 中添加 <base href="/"/>,但我在控制台中收到了一个很好的红色警告,所以这可能不是最好的主意:
警告:使用 is 自动设置 basename 已弃用并将在下一个主要版本中删除。这 的语义与 basename 略有不同。请 在 createHistory 的选项中显式传递基本名称
【问题讨论】:
标签: javascript html reactjs react-router