We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react如何实现组件预加载?
The text was updated successfully, but these errors were encountered:
import React {Suspense,lazy} from 'react' const LoadableComponent = lazy(() => import("./my-component")); class Test extends React.Component { render () { return ( <Suspense fallback={<div>Loading...</div>}> <LoadableComponent /> </Suspense>) } } export default Test
import React from 'react' import loadable from 'react-loadable' const LoadableComponent = Loadable({ loader: () => import('./my-component'), loading: <div>Loading...</div>, }); class Test extends React.Component { render () { return ( <div> <LoadableComponent/> </div>) } } export default Test
要安装配置babel-plugin-syntax-dynamic-import,否则会报语法错误
npm i react-loadable babel-plugin-syntax-dynamic-import -D
在.babelrc文件中添加配置
{ "presets": [ "react" ], "plugins": [ "syntax-dynamic-import" ] }
Sorry, something went wrong.
No branches or pull requests
react如何实现组件预加载?
The text was updated successfully, but these errors were encountered: