当前位置:   article > 正文

react中实现路由懒加载_react 定义路由需要createelement lazy

react 定义路由需要createelement lazy

不同于v3的component:()=>import ""

react中的路由懒加载需要引入lazy()函数.

下面就是示例啦:

  1. // import LoginView from "../views/login/LoginView";
  2. // import RegisterView from "../views/register/RegisterView";
  3. // import JiedanView from "../views/jiedan/JiedanView";
  4. import {lazy} from "react"
  5. const JiedanView = lazy(()=> import("../views/jiedan/JiedanView"))
  6. const RegisterView = lazy(()=> import("../views/register/RegisterView"))
  7. const LoginView = lazy(()=>import("../views/login/LoginView"))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/575369
推荐阅读
相关标签
  

闽ICP备14008679号