如官网描述: https://reactjs.org/docs/code...
import React, { Suspense } from 'react';
const LuckyWheel = lazy(() => import('@lucky-canvas/react').then(({ LuckyWheel }) => {
return { default: LuckyWheel};
}));
function MyComponent() {
return (
<div>
<Suspense fallback={<div>Loading...</div>}>
<section>
<LuckyWheel />
</section>
</Suspense>
</div>
);
}
结果:
正常运行。但是LuckyWheel 没有被单独打包。