小编its*_*s30的帖子

根目录下的 React-router 可选路径参数

我对如何从根执行(多个)可选路径参数有点困惑。我正在使用react-router 3和redux 4.3。

据我了解,(/:param1)(/:param2)应该可以工作,但加载应用程序时出现以下错误:

[react-router] 位置“/property/3633”与任何路由不匹配。

索引.js:

import React from 'react';

import ReactDOM from 'react-dom';

import { Provider } from 'react-redux';

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

import { syncHistoryWithStore } from 'react-router-redux';

import configureStore from './store/configureStore';

import {MyContainer} from "./containers/MyContainer";

const store = configureStore();
const history = syncHistoryWithStore(browserHistory, store);

ReactDOM.render(
    <Provider store={store}>
        <Router history={history}>
            <Route path="/(/:Type)(/:Id)" component={MyContainer}/>
        </Router>
    </Provider>,
    document.getElementById('root'),
);
Run Code Online (Sandbox Code Playgroud)

仅供参考我已经尝试过:

path="(/:Type)(/:Id)" 
path="(/:Type)/(/:Id)" 
path="/(/:Type)/(/:Id)" 
path="/(/:Type)(/:Id)" 
path="/:Type/:Id" // Only works when params are …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router react-router-redux

5
推荐指数
1
解决办法
1329
查看次数

标签 统计

react-router ×1

react-router-redux ×1

reactjs ×1