来源:未知 时间:2024-05-12 21:44 作者:小飞侠 阅读:次
[导读] 根据条件进行组件懒加载 importReact,{lazy,Suspense}fromreactimport{BrowserRouterasRouter,Link,Route,Routes}fromreact-router-domconstHome=lazy(()=import(/*webpackChunkName:Home*/./page/Home))constList=lazy(()=import(/*webpackChunkN...
根据条件进行组件懒加载 import React, { lazy, Suspense} from 'react' import { BrowserRouter as Router, Link, Route, Routes } from 'react-router-dom' const Home = lazy(() => import(/*webpackChunkName: "Home"*/'./page/Home') ) const List = lazy(() => import(/*webpackChunkName: "List"*/'./page/List') ) export default function App() { let LazyComponent = null if (false) { LazyComponent = Home } else { LazyComponent = List } return ( <> <header>header</header> <Suspense fallback={<div>loading...</div>}> <LazyComponent /> </Suspense> <footer>footer</footer> </> ) } 以上就是react组件条件判断懒加载全部内容,感谢大家支持自学php网。 |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com