React路由懒加载:使用TS和BrowserRouter实现组件按需加载
import\s+React\s+from\s+'react';\nimport\s+{\s+BrowserRouter\s+as\s+Router,\s+Route,\s+Switch\s+}\s+from\s+'react-router-dom';\n\nconst\s+Home\s+=\s+React.lazy\s+(\s=>\s+import('./components/Home'));\nconst\s+About\s+=\s+React.lazy\s+(\s=>\s+import('./components/About'));\nconst\s+Contact\s+=\s+React.lazy\s+(\s=>\s+import('./components/Contact'));\n\nconst\s+App:\s+React.FC\s+=\s+()\s=>\s+{\n\s+return\s+(\n\s+\s+

原文地址: http://www.cveoy.top/t/topic/qA9v 著作权归作者所有。请勿转载和采集!