node.js - react应用加了react-redux后webpack打包后页面显示空白,也没有报错

查看:216
本文介绍了node.js - react应用加了react-redux后webpack打包后页面显示空白,也没有报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

开发环境用webpack-dev-server运行是可以的,生产模式下打包后把文件放到tomcat下打开首页就是空白页了,而且没有报错

下面是我app.js里的代码,如果去掉Provider,直接引入组件是可以显示的,加上react-redux后页面就是空白了,请各位帮我看看问题

/* 
    --- 引入切换动画插件 ---
*/
const App = ({ children, location }) => (
    <div className='routerBox'>
        <QueueAnim>
            {React.cloneElement(children, {key: location.pathname})}
        </QueueAnim>
    </div>
)
/* 
    --- 注册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);

解决方案

已经解决了,是路由history的问题

这篇关于node.js - react应用加了react-redux后webpack打包后页面显示空白,也没有报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆