
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
dva-router-config
Advanced tools
#### 项目介绍 使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
yarn add dva-router-config
或者
npm i -S dva-router-config
1.基础示例
// routes.js
export default [
{
path: '/',
exact: true,
component: () => import('../IndexPage'),
},
{
path: '/person',
component: () => import('./_layout'),
models: () => [
import('src/models/person'),
],
routes: [
{
path: '/person/redirect',
exact: true,
redirect: '/person/home',
},
{
path: '/person/home',
exact: true,
component: () => import('./Home'),
models: () => [
import('src/models/person/home'),
import('src/models/person/dict'),
],
},
{
path: '/person/mine',
exact: true,
component: () => import('./Mine'),
models: () => [
import('src/models/person/mine'),
import('src/models/person/dict'),
],
},
]
}
];
// router.js
import React from 'react';
import { Router } from 'dva/router';
import { convertRoutes, } from 'dva-router-config';
import routesConfig from './routes/Person/routes';
function RouterConfig({ app, history }) {
return (
<Router history={history}>
{convertRoutes(routesConfig, { app })}
</Router>
);
}
export default RouterConfig;
// _layout.js
import React, { PureComponent } from 'react';
import { Link } from 'react-router-dom';
import { renderRoutes } from 'dva-router-config';
export default class Layout extends PureComponent {
render () {
console.warn('render layout');
const { route = {} } = this.props;
return (
<div>
<ul>
<li>
<Link to={'/person/home'}>home</Link>
</li>
<li>
<Link to={'/person/mine'}>mine</Link>
</li>
<li>
<Link to={'/person/redirect'}>redirect</Link>
</li>
</ul>
{renderRoutes(route.routes)}
</div>
);
}
}
FAQs
#### 项目介绍 使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
The npm package dva-router-config receives a total of 2 weekly downloads. As such, dva-router-config popularity was classified as not popular.
We found that dva-router-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.