umi2通过注释扩展路由
/**
* title: About Page
* Routes:
* - ./routes/PrivateRoute.js
*/
umi3中不生效,改成直接给页面组件加属性
import React from 'react';
import styles from './about.css';
function about(){
return (
<div>
<h1 className={styles.title}>Page about</h1>
</div>
);
}
about.wrappers = ['@/pages/routes/PrivateRoute.js']
export default about
保存后生成的routes.js
{
"path": "/about",
"exact": true,
"component": require('@/pages/about.js').default,
"wrappers": [require('@/pages/routes/PrivateRoute.js').default]
},