node.js - react應用加了react-redux后webpack打包后頁面顯示空白,也沒有報錯
問題描述
開發環境用webpack-dev-server運行是可以的,生產模式下打包后把文件放到tomcat下打開首頁就是空白頁了,而且沒有報錯
下面是我app.js里的代碼,如果去掉Provider,直接引入組件是可以顯示的,加上react-redux后頁面就是空白了,請各位幫我看看問題
/* --- 引入切換動畫插件 ---*/const App = ({ children, location }) => ( <p className=’routerBox’><QueueAnim> {React.cloneElement(children, {key: location.pathname})}</QueueAnim> </p>)/* --- 注冊store ---*/const store = createStore(reducer);/* --- 路由 ---*/const renders = () => { render(<Provider store={store}> <Router history={browserHistory}><Route path =’/’ component={App}> <IndexRoute component={Signin}/> <Route path=’signin’ component={Signin}/> <Route path=’index’ component={Index}/> <Route path=’modifypwd’ component={Modifypwd}/> <Route path=’userdetail’ component={Userdetail}/> <Route path=’useredit’ component={Useredit}/> <Route path=’customerItem’ component={CustomerItem}/> <Route path=’customerAdd’ component={CustomerAdd}/> <Route path=’customerDetail/:id’ component={CustomerDetail}/> <Route path=’customerWriteinto’ component={CustomerWriteinto}/> <Route path=’customerWriteintoEdit’ component={CustomerWriteintoEdit}/> <Route path=’customerTran’ component={CustomerTran}/> <Route path=’customerInto’ component={CustomerInto}/> <Route path=’customerList’ component={CustomerList}/> <Route path=’customerEdit’ component={CustomerEdit}/></Route> </Router></Provider>,document.getElementById(’appLogin’) );}renders();/* --- 監聽當前狀態,判斷是否重新渲染 ---*/store.subscribe(renders);
問題解答
回答1:已經解決了,是路由history的問題
回答2:謝謝樓主,也幫我解決了問題。
相關文章:
