找不到bundle.js

时间:2016-09-13 18:34:21

标签: javascript reactjs react-router

我正在构建一个应用程序,使用的反应是来自于反应/路由器2.0和lite-server的browserHistory。路由器代码如下:

const appRouter = (
    <Router history={browserHistory}>
        <Route path="/" component={App}>
            <IndexRoute component={LandingPage}/>
            <Route path="/posts" component={Posts}/>
            <Route path="/posts/:postId" component={Post}/>
        </Route>
    </Router>
);

错误是X GET http://localhost:3000/posts/lib/bundle.js

此错误仅在网址为http://localhost:3000/posts/somePostId且刷新页面或

后发生

lib / bundle.js文件假设从root&#39; /&#39;加载,但它正试图从&#39; / posts /&#39;加载。

我刚从hashHistory切换到browserHistory,切换后发生错误。

1 个答案:

答案 0 :(得分:0)

因为您有路线<Route path="/posts/:postId" component={Post}/>

与您的bundle.js:http://localhost:3000/posts/lib/bundle.js的路径匹配,请尝试将您的js文件移动到另一个文件夹或使用其他路径。