1 回答
TA贡献1802条经验 获得超5个赞
routes.map(({path, models, component, ...dynamics},key)) => (
if (model) {
dynamics.models = () => models();
}
dynamics.component = () => component();
<Router key={key}
exact
path={path}
component={dynamic({
app,
...dynamics
})}
)
你要把model引入。
if (model) {
dynamics.models = () => models();
}
dynamics.component = () => component();
//相当于:
const UserPageComponent = dynamic({
app,
models: () => [
import('./models/users'),
],
component: () => import('./routes/UserPage'),
});
//你需要把model引入你的组件。。。。
routes.map(({path, models, component, ...dynamics},key)) => {
if (models) {
dynamics.models = () => models();
}
dynamics.component = () => component();
return (
<Router key={key}
exact
path={path}
component={dynamic({
app,
...dynamics
})}
)
}
添加回答
举报