Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在redux中使用react路由器时如何修复空白屏幕_Reactjs_Webpack_Redux_React Router - Fatal编程技术网

Reactjs 在redux中使用react路由器时如何修复空白屏幕

Reactjs 在redux中使用react路由器时如何修复空白屏幕,reactjs,webpack,redux,react-router,Reactjs,Webpack,Redux,React Router,对于localhost,这是正常的。但是,当我使用“NPM运行构建”并将源上传到服务器现场时,我的页面是空白屏幕,没有任何错误,警告。这是我的密码。谢谢你的帮助 'use strict'; import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import { createStore , applyMiddleware } from '

对于localhost,这是正常的。但是,当我使用“NPM运行构建”并将源上传到服务器现场时,我的页面是空白屏幕,没有任何错误,警告。这是我的密码。谢谢你的帮助

    'use strict';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { createStore , applyMiddleware  } from 'redux';

import dataService from './box-message/api';

import switchsApp from './box-message/reducers';
import App from './box-message/components';

import {Router, Route, browserHistory} from 'react-router';
import MyProfile from './profile';

import '../index.html';
import '../libs/js/socketcluster.min.js';
import '../libs/css/styles.min.css';

window.store = createStore(switchsApp , applyMiddleware(dataService));

window.store.dispatch({type: 'GET_MESSAGE_DATA'});

render(
    <Provider store={window.store} >
        <Router history={browserHistory}>
            <Route path="/" component={App} />
            <Route path="/question" component={MyProfile} />
        </Router>
    </Provider>
    ,document.getElementById('root')
)
“严格使用”;
从“React”导入React;
从'react dom'导入{render};
从'react redux'导入{Provider};
从“redux”导入{createStore,applyMiddleware};
从“/box message/api”导入数据服务;
从“/box message/reducers”导入开关SAPP;
从“/box消息/组件”导入应用程序;
从“react Router”导入{Router,Route,browserHistory};
从“/profile”导入MyProfile;
导入“../index.html”;
导入“../libs/js/socketcluster.min.js”;
导入“../libs/css/styles.min.css”;
window.store=createStore(switchsApp、applyMiddleware(数据服务));
dispatch({type:'GET_MESSAGE_DATA'});
渲染(
,document.getElementById('root'))
)
试试看


我在路由器中编辑了一些内容。我使用“browserHistory”来创建一个漂亮的url它在本地主机上运行得非常好。我可以很容易地在索引和配置文件页面之间交换路由器。但我在上传服务器直播时又遇到了“黑屏”问题(我的域名是https),所以我和他们混淆了。我需要帮助。谢谢大家

。P/s:我使用react路由器:v3.0.2

import {Router, Route, browserHistory , hashHistory, IndexRoute} from 'react-router';

class App extends React.Component{

    constructor(props) {

        super(props);
    }

    render() {
        return (
            <section> 
                {this.props.children}
            </section>
        )
    }
}

render(
    <Provider store={window.store}>
        <Router history={browserHistory}>
            <Route path="/" component={App}>
                <IndexRoute component={BoxMessage} />
                <Route path="/profile" component={MyProfile} />
            </Route>
        </Router>
    </Provider> 
    ,
    document.getElementById('root')
)
从'react Router'导入{Router,Route,browserHistory,hashHistory,IndexRoute};
类应用程序扩展了React.Component{
建造师(道具){
超级(道具);
}
render(){
返回(
{this.props.children}
)
}
}
渲染(
,
document.getElementById('root'))
)

我在使用react router运行子文件夹时找到了方法

import {Router, Route, browserHistory , hashHistory, IndexRoute , useRouterHistory  } from 'react-router';
import { createHistory } from 'history'

const appHistory = useRouterHistory(createHistory)({
  basename: "/demos/v1"
});
render(
    <Provider store={window.store}>
        <Router history={appHistory}>
            <Route path="/" component={App}>
                <IndexRoute component={BoxMessage} />
                <Route path="/profile" component={MyProfile} >
                    <Route path="/profile/:id" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name/:last_name" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name/:last_name/:avatar" component={MyProfile}/>
                 </Route>
            </Route>
        </Router>
    </Provider> 
    ,
    document.getElementById('root')
) 
从'react Router'导入{Router,Route,browserHistory,hashHistory,IndexRoute,useRouterHistory};
从“历史”导入{createHistory}
const appHistory=useRouterHistory(createHistory)({
basename:“/demos/v1”
});
渲染(
,
document.getElementById('root'))
) 

为什么在第1行有
的“使用技巧”?也许你是有意的?这是解决问题的好机会,你需要分享更多关于部署过程的信息。例如,您使用什么来构建应用程序?一些语法建议使用巴别塔进行现代构建过程。“服务器活动”所在的计算机与您的开发环境类似吗?浏览器在空白页面上给你的日志是什么?抱歉。这是我关于词汇的错误。我会修好的你试着移除缓存了吗?因为你们说你们要上传到远程主机,所以这可能是一个问题。我删除了浏览器的缓存,但它是一样的。我将尝试搜索更多。谢谢,Thaánhungù我非常了解你的想法。我看到了问题所在。如果我用“domain.net”=>运行域,它会工作。但是如果我运行“domain.net/demos/”=>它将无法工作。我将使用run with子文件夹搜索路径
import {Router, Route, browserHistory , hashHistory, IndexRoute , useRouterHistory  } from 'react-router';
import { createHistory } from 'history'

const appHistory = useRouterHistory(createHistory)({
  basename: "/demos/v1"
});
render(
    <Provider store={window.store}>
        <Router history={appHistory}>
            <Route path="/" component={App}>
                <IndexRoute component={BoxMessage} />
                <Route path="/profile" component={MyProfile} >
                    <Route path="/profile/:id" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name/:last_name" component={MyProfile}/>
                    <Route path="/profile/:id/:fisrt_name/:last_name/:avatar" component={MyProfile}/>
                 </Route>
            </Route>
        </Router>
    </Provider> 
    ,
    document.getElementById('root')
)