React Router怎么用
发布网友
发布时间:2022-05-07 22:35
我来回答
共1个回答
热心网友
时间:2022-04-22 12:35
以下是我做的一个案例的route配置信息,他是用来链接你的每个页面的,简单点就是超链接里面的一个关键id一样,来识别页面的属性,path属性就是链接里面要引用的,
例如:http://localhost:3000/#/recharge?_k=3l0sz9。这里的recharge就是path属性。
import React from 'react';
import { Route } from 'react-router';
/* containers */
import { App } from 'containers/App';
import { Home } from 'containers/Home';
import { Activity } from 'containers/Activity';
import { List } from 'containers/List';
import { UserInfomation } from 'containers/User/UserInfomation';
import { UserMain } from 'containers/User/UserMain';
import { Recharge } from 'containers/User/Recharge';
import { Rules } from 'containers/Rules/Rules';
import { Ordered } from 'containers/Order/Ordered';
export default (
<Route path="/" component={App}>
<Route path="home" component={Home} />
<Route path="list" component={List} />
<Route path="activity" component={Activity} />
<Route path="userInfomation" component={UserInfomation} />
<Route path="usermain" component={UserMain} />
<Route path="recharge" component={Recharge} />
<Route path="rules" component={Rules} />
<Route path="ordered" component={Ordered} />
</Route>
);