为了账号安全,请及时绑定邮箱和手机立即绑定

具有BrowserRouter / browserHistory的React-router在刷新时

具有BrowserRouter / browserHistory的React-router在刷新时

www说 2019-07-27 14:06:42
具有BrowserRouter / browserHistory的React-router在刷新时不起作用我有以下webpack配置文件:var webpack = require('webpack');var path = require('path');var BUILD_DIR = path.resolve(__dirname, 'src/client/public');var APP_DIR = path.resolve(__dirname, 'src/client/app');var config = {     entry: [         APP_DIR + '/config/routes.jsx',         'webpack/hot/dev-server',         'webpack-dev-server/client?http://localhost:8080'     ],   output: {     publicPath: 'http://localhost:8080/src/client/public/'   },   module : {     loaders : [       {         test: /\.jsx?$/,         loader: 'babel-loader',         include: APP_DIR,         exclude: /node_modules/,         query: {             presets: ['es2015']         }       },       {         test: /\.scss$/,         loaders: [ 'style', 'css', 'sass' ]       },        {         test: /\.json$/,          loader: "json-loader"      }     ]   }};module.exports = config;我想要做的就是在localhost上运行我的应用程序,但是当我点击时:“ http:// localhost:8080 / src / client / home ”(根据我的routes.jsx和运行webpack-dev-server之后)import React from 'react';import { Route, Router, browserHistory } from 'react-router';import ReactDOM from 'react-dom';import Wrapper       from './../components/wrapper.jsx';import Home          from './../components/home.jsx';import Projects      from './../components/projects.jsx';import SingleProject from './../components/projectContent/singleProject.jsx';import About         from './../components/aboutUs.jsx'ReactDOM.render((     <Router history={browserHistory} >         <Route path="/" component={Wrapper} >             <Route path="home" component={Home} />             <Route path="projects" component={Projects} />             <Route path="projects/:id" component={SingleProject} />             <Route path="about" component={About} />         </Route>     </Router>), document.getElementById('app'));我明白了“不能GET / src / client / home”。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1497 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信