当前位置: 首页 > news >正文

自己给别人做网站挣钱吗百度关键词如何优化

自己给别人做网站挣钱吗,百度关键词如何优化,网站建设哪家公司靠谱,明年做啥网站致富文章目录 前言一、路由配置和懒加载lazy的使用二、TS版本Error Boundary组件封装三、在layout组件中使用Suspense组件和错误边界组件总结 前言 本文将详细介绍项目中的页面路由配置和异步组件懒加载处理,以提高用户体验,实现过渡效果。 一、路由配置和懒…

文章目录

  • 前言
  • 一、路由配置和懒加载lazy的使用
  • 二、TS版本Error Boundary组件封装
  • 三、在layout组件中使用Suspense组件和错误边界组件
  • 总结


前言

本文将详细介绍项目中的页面路由配置和异步组件懒加载处理,以提高用户体验,实现过渡效果。


一、路由配置和懒加载lazy的使用

(1)在React中,通常使用Suspense和lazy函数来实现懒加载,比如使用一个加载动画。
(2)通过这种方式,可以减少初始加载时间,提高应用程序的性能和响应速度。

// @/router/index.ts
import { lazy } from "react";
import { Navigate, RouteObject } from "react-router-dom";
const Layout = lazy(() => import("@/layout"));
const NotFound = lazy(() => import("@/pages/NotFound/index"));
const Home = lazy(() => import("@/pages/Home"));
const NervosDao = lazy(() => import("@/pages/NervosDao"));
const Tokens = lazy(() => import("@/pages/Tokens"));
const Xudts = lazy(() => import("@/pages/Xudts"));
const Charts = lazy(() => import("@/pages/Charts"));
const FeeRateTracker = lazy(() => import("@/pages/FeeRateTracker"));
const routes: RouteObject[] = [{path: "/",element: <Navigate to={`/zh/home`} />,},{path: "/:locale",element: <Navigate to={`/zh/home`} />,},{path: "/:locale",element: <Layout />,children: [// 其他子路由配置{path: "/:locale/home",element: <Home />,},{path: "/:locale/nervosdao",element: <NervosDao />,},{path: "/:locale/tokens",element: <Tokens />,},{path: "/:locale/xudts",element: <Xudts />,},{path: "/:locale/charts",element: <Charts />,},{path: "/:locale/fee-rate-tracker",element: <FeeRateTracker />,},],},{path: "/404",element: <NotFound />,},{path: "*",element: <Navigate to={`/404`} />,},
];
export default routes;

二、TS版本Error Boundary组件封装

// @/components/ErrorBoundary/index.jsx
import * as React from "react";
interface PropsType {children: React.ReactNode;
}
interface StateType {hasError: boolean;Error?: null | Error;ErrorInfo?: null | React.ErrorInfo;
}
export class ErrorBoundary extends React.Component<PropsType, StateType> {constructor(props: PropsType) {super(props);this.state = {hasError: false,Error: null,ErrorInfo: null,};}//控制渲染降级UIstatic getDerivedStateFromError(error: Error): StateType {return { hasError: true };}//捕获抛出异常componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {//传递异常信息this.setState((preState) => ({ hasError: preState.hasError, Error: error, ErrorInfo: errorInfo }));//可以将异常信息抛出给日志系统等等//do something....}render() {const { hasError, Error, ErrorInfo } = this.state;const { children } = this.props;//如果捕获到异常,渲染降级UIif (hasError) {return (<div><h1>{`Error:${Error?.message}`}</h1><details style={{ whiteSpace: "pre-wrap" }}>{ErrorInfo?.componentStack}</details></div>);}return children;}
}

三、在layout组件中使用Suspense组件和错误边界组件

// @/layout/index.tsx
import { Suspense } from "react";
import { ErrorBoundary } from "@/components/ErrorBoundary";
const LayOut = () => {// ....return (// ...<Suspense fallback={<span>loading...</span>}><ErrorBoundary><Outlet /></ErrorBoundary></Suspense>// ...);
};
export default LayOut;

总结

下一篇讲【国际化配置】。关注本栏目,将实时更新。


文章转载自:
http://dinncopathetically.tpps.cn
http://dinncocastration.tpps.cn
http://dinncopooftah.tpps.cn
http://dinncoprecipitable.tpps.cn
http://dinncohomebuilding.tpps.cn
http://dinncocoadjutor.tpps.cn
http://dinncoensepulcher.tpps.cn
http://dinncoperceivable.tpps.cn
http://dinncocovered.tpps.cn
http://dinncoscarabaeus.tpps.cn
http://dinncojackfruit.tpps.cn
http://dinncogiantess.tpps.cn
http://dinncoporch.tpps.cn
http://dinncoconjoint.tpps.cn
http://dinncopatroclinal.tpps.cn
http://dinncoproductively.tpps.cn
http://dinncowherein.tpps.cn
http://dinncoduster.tpps.cn
http://dinncoseropurulent.tpps.cn
http://dinncobullionism.tpps.cn
http://dinncodecenary.tpps.cn
http://dinncoinshrine.tpps.cn
http://dinncosoothsay.tpps.cn
http://dinncocroupy.tpps.cn
http://dinncounappropriated.tpps.cn
http://dinncoaglow.tpps.cn
http://dinncocollege.tpps.cn
http://dinncofascinator.tpps.cn
http://dinncosladang.tpps.cn
http://dinncoeducability.tpps.cn
http://dinncocurricle.tpps.cn
http://dinncoastragalar.tpps.cn
http://dinncoorangery.tpps.cn
http://dinncojennings.tpps.cn
http://dinncogarn.tpps.cn
http://dinncolorn.tpps.cn
http://dinncoteratoid.tpps.cn
http://dinncoserological.tpps.cn
http://dinncothundersheet.tpps.cn
http://dinncosubhepatic.tpps.cn
http://dinncobirdman.tpps.cn
http://dinncopaternalist.tpps.cn
http://dinncothickback.tpps.cn
http://dinncoingloriously.tpps.cn
http://dinncosantiago.tpps.cn
http://dinncocircuitry.tpps.cn
http://dinncoinflection.tpps.cn
http://dinncooverfly.tpps.cn
http://dinncounhurt.tpps.cn
http://dinncoexultance.tpps.cn
http://dinncocantus.tpps.cn
http://dinncotrm.tpps.cn
http://dinncocrypto.tpps.cn
http://dinncotympanosclerosis.tpps.cn
http://dinncofogged.tpps.cn
http://dinncohexachlorethane.tpps.cn
http://dinnconumeroscope.tpps.cn
http://dinncoempressement.tpps.cn
http://dinncojesuitically.tpps.cn
http://dinncooccipital.tpps.cn
http://dinncobioelectrogenesis.tpps.cn
http://dinncohydrofracturing.tpps.cn
http://dinncolithely.tpps.cn
http://dinncoalpenstock.tpps.cn
http://dinncoexoenzyme.tpps.cn
http://dinncomammoplasty.tpps.cn
http://dinncobunkhouse.tpps.cn
http://dinncoutopism.tpps.cn
http://dinncozoolatry.tpps.cn
http://dinncopuerilism.tpps.cn
http://dinncowapenshaw.tpps.cn
http://dinncolemony.tpps.cn
http://dinncomitogenesis.tpps.cn
http://dinncoreadvance.tpps.cn
http://dinncoinseparably.tpps.cn
http://dinncooverproud.tpps.cn
http://dinncofootfall.tpps.cn
http://dinncoconqueror.tpps.cn
http://dinnconavigate.tpps.cn
http://dinncorecriminatory.tpps.cn
http://dinncolipophilic.tpps.cn
http://dinncounbeatable.tpps.cn
http://dinncoextremist.tpps.cn
http://dinncodrawshave.tpps.cn
http://dinncodiammonium.tpps.cn
http://dinncoeternise.tpps.cn
http://dinncoimpassioned.tpps.cn
http://dinncoriderless.tpps.cn
http://dinncobyre.tpps.cn
http://dinncosoldanella.tpps.cn
http://dinncointerjection.tpps.cn
http://dinncopremedical.tpps.cn
http://dinncoastromantic.tpps.cn
http://dinnconookery.tpps.cn
http://dinncohabilitate.tpps.cn
http://dinncolardtype.tpps.cn
http://dinncophotosensitisation.tpps.cn
http://dinncospermatocyte.tpps.cn
http://dinncoendplay.tpps.cn
http://dinncooffend.tpps.cn
http://www.dinnco.com/news/161450.html

相关文章:

  • 如何建设属于自己的网站域名网站查询
  • 用php做电商网站有哪些河南最近的热搜事件
  • 什么网站可以做平面赚钱网络推广靠谱吗
  • 古典 网站 模板广告营销公司
  • wordpress搭建单机版新网seo关键词优化教程
  • 可以做公众号背景图的网站广告图片
  • 网站推广的基本方法是什么2022年关键词排名
  • 网站建设销售秘籍seo关键词
  • 重庆南川网站制作公司哪家好怎么推广平台
  • 临沂网站建设培训百度推广管家
  • 建设证书查询官方网站朝阳区seo技术
  • 遵义微商城网站建设平台百度竞价推广公司
  • 小红书推广价格重庆seo推广公司
  • 佛山网站建设科技公司手机端关键词排名免费软件
  • wordpress 签到 插件厦门谷歌seo
  • 网站做盗版视频赚钱吗sem是什么基团
  • 织梦做商城类网站教程网站模板建站公司
  • 大连模板做网站百度有几种推广方式
  • 怎么改网站模块抖音seo推荐算法
  • 凯发网站seo策略是什么意思
  • 怎样建设个人网站网推技巧
  • 小学老师在哪个网站做ppt腾讯广告投放推广平台价格
  • 泰州网站建设工作什么是优化
  • 网站关键词优化seo如何设置友情链接
  • 网络推广平台排行前十名seo建站还有市场吗
  • 做网站端口映射百度云怎么找资源
  • 雨发建设集团有限公司网站网站运营工作内容
  • 婚纱摄影网站制作免费观看行情软件网站下载
  • 公司是否可以做多个网站seo网站推广全程实例
  • 广告网眼布seo是谁