react.js - react本地执行npm run build打包之后,本地打开index.html文件,出现空白页面
本文介绍了react.js - react本地执行npm run build打包之后,本地打开index.html文件,出现空白页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
看了下浏览器,如果去掉路由的话,可以正常访问,请问是什么问题呢
const router = (
<Router>
<Provider store={store}>
<App>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/home" component={Home} />
<Route path="/test" component={Test} />
<Route path="/box" component={Box} />
<Route path="/manage/:hotelName" render={props=>
<Manage {...props}/>
} />
<Route path="/menu" component={Menu} />
<Route path="/chart/:id" render={props=>
<Chart {...props}/>
}>
</Route>
</Switch>
</App>
</Provider>
</Router>
)
export default router
class App extends Component {
componentDidUpdate() {
}
render() {
return (
<div className="App">
<section>
{this.props.children}
</section>
</div>
);
}
}
export default App;
解决方案
已经解决了,引入路由的时候使用HashRouter即可
这篇关于react.js - react本地执行npm run build打包之后,本地打开index.html文件,出现空白页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文