react 楼层按需加载 @loadable/component
import * as React from 'react'; import loadable from '@loadable/component'; export default (name: string, data) => { const AsyncPage = loadable(() => import(`../floor/${name}`)); return class extends React.Component<any> { public render() { return ( <AsyncPage {...data} /> ); } }; };
注意: 使用懒加载的楼层,不能通过其它的形式引入到页面了, 否则会导致拆分失败