react-router-dom
Route主件
path(string): 路由匹配路径。(没有path属性的Route 总是会 匹配);
exact(bool):为true时,则要求路径与location.pathname必须完全匹配;
strict(bool):true的时候,有结尾斜线的路径只能匹配有斜线的location.pathname;
Route渲染方式
Switch主件
路由嵌套
V4的嵌套,和V2V3相当不同
V4必须在主件的内部嵌套route例子如下:
import React, {Component} from 'react';
import {Route} from 'react-router-dom';
import lazyLoad from '../lazyLoad';
import Index from 'bundle-loader?lazy&name=home!./index';
export default class Login extends Component {
render() {
return (
<div>测试
<Route
path={this.props.match.path + '/index'}
render={() => {
return lazyLoad(Index, {
...this.props
});
}}></Route>
</div>
);
}
}
评论 (0)