Javascript 反应路由器:位置“/&引用;没有匹配任何路线
这是我的密码Javascript 反应路由器:位置“/&引用;没有匹配任何路线,javascript,reactjs,react-router,Javascript,Reactjs,React Router,这是我的密码 import React from 'react'; import { Router, Route, IndexRoute, hashHistory } from 'react-router'; import Home from './components/Home'; import ArtistMain from './components/artists/ArtistMain'; const componentRoutes = { component: Home,
import React from 'react';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import Home from './components/Home';
import ArtistMain from './components/artists/ArtistMain';
const componentRoutes = {
component: Home,
path: "/",
indexRoute: { component: ArtistMain },
childRoutes: [
{
path: "artists/new",
getComponent(location, cb) {
System.import('./components/artists/ArtistCreate')
.then(module => cb(null, module.default));
}
},
{
path: "artists/:id",
getComponent(location, cb) {
System.import('./components/artists/ArtistDetail')
.then(module => cb(null, module.default));
}
},
{
path: "artists/:id/edit",
getComponent(location, cb) {
System.import('./components/artists/ArtistEdit')
.then(module => cb(null, module.default));
}
}
]
};
const Routes = () => {
return (
<Router history={hashHistory} router={componentRoutes} />
);
};
export default Routes;
这些是我的依赖项:
"dependencies": {
"faker": "^3.1.0",
"lodash": "^4.17.2",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-input-range": "^0.9.2",
"react-redux": "^4.4.6",
"react-router": "^3.0.0",
"redux": "^3.6.0",
"redux-form": "^6.3.2",
"redux-thunk": "^2.1.0"
},
为什么不是一个重复的问题:因为另一个SO问题已经解决,迁移到react router v3,我已经在这个版本中,或者导入IndexRoute
而不是IndexRoute
或类似的,但我的代码中没有这个输入错误;另外,我不介意用hashHistory
替换browserhistory
,因为我已经在使用它了;另外,关于这个主题的99%的问题是使用声明性语法,而我使用的是js
这是因为
路由器
属性应该是路由
:
const Routes = () => {
return (
<Router history={hashHistory} routes={componentRoutes} />
);
};
const Routes=()=>{
返回(
);
};
你赢了。谢谢这是我第一次用这种方式发送邮件,但没有注意到这个打字错误。非常感谢,你救了我一命:)
const Routes = () => {
return (
<Router history={hashHistory} routes={componentRoutes} />
);
};