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

营销网站建设企划案例淘宝搜索关键词排名

营销网站建设企划案例,淘宝搜索关键词排名,做原创短视频网站,自己做的网站给人攻击了怎么办react-router 为了满足开发者更多路由历史存储场景,提供了以下几种模式: 浏览器原生历史记录 浏览器 hash 内存型 服务端记录 以上实现分别对应于一下 API 实现: createBrowserRouter:浏览器提供的历史管理。 createHashRou…

react-router 为了满足开发者更多路由历史存储场景,提供了以下几种模式:

  • 浏览器原生历史记录

  • 浏览器 hash

  • 内存型

  • 服务端记录

以上实现分别对应于一下 API 实现:

  • createBrowserRouter:浏览器提供的历史管理。

  • createHashRouter:基于 hash 的路由管理,#hello,但是呢通常 # 又可以作为锚链接。

  • createMemoryRouter:内存型路由,路由的管理存储在内存中。

  • createStaticRouter:SSR 服务端的。

1. createBrowserRouter

通过浏览器原生路由进行路由态管理,页面跳转通过 pushState、popState 方法实现。

import * as React from "react";
import * as ReactDOM from "react-dom";
import {createBrowserRouter,RouterProvider} from "react-router-dom";import Root, { rootLoader } from "./routes/root";
import Team, { teamLoader } from "./routes/team";const router = createBrowserRouter([{path: "/",element: <Root />,loader: rootLoader,children: [{path: "team",element: <Team />,loader: teamLoader,},],},
]);ReactDOM.createRoot(document.getElementById("root")).render(<RouterProvider router={router} />
);

需要注意的是,使用 browserRouter,一般都需要使用类似 Nginx 做静态资源代理,另外需要注意 404 的情况,一般都需要添加 try_files 处理。

location / {try_files $uri /index.html;
}

2. createHashRouter(不推荐)

请注意,这个方法非常不推荐,他的用武之地就在于,我们没有 Nginx 作为静态资源代理,我们可能就无法使用浏览器历史作为我们路由状态的存储,这时可以选择 hash router 方案,但是注意,真的非常不推荐,除非是你自己的个人项目。

import * as React from "react";
import * as ReactDOM from "react-dom";
import {createHashRouter,RouterProvider} from "react-router-dom";import Root, { rootLoader } from "./routes/root";
import Team, { teamLoader } from "./routes/team";const router = createHashRouter([{path: "/",element: <Root />,loader: rootLoader,children: [{path: "team",element: <Team />,loader: teamLoader,},],},
]);ReactDOM.createRoot(document.getElementById("root")).render(<RouterProvider router={router} />
);

3. createMemoryRouter

用于创建一个内存型路由,路由表与历史记录栈存储在内存中,当页面刷新时,路由信息丢失。

import * as React from "react";
import * as ReactDOM from "react-dom";
import {createMemoryRouter,RouterProvider} from "react-router-dom";import CalendarEvent from "./routes/calendarEvent";const routes = [{path: "/events/:id",element: <CalendarEvent />,loader: () => FAKE_EVENT,},
];const router = createMemoryRouter(routes, {initialEntries: ["/", "/events/123"],initialIndex: 1,
});ReactDOM.createRoot(document.getElementById("root")).render(<RouterProvider router={router} />
);

其实这种内存型历史记录,我们自己通过状态管理都能够轻松实现,他这就类似于我们定义了集中状态,然后当状态更新时渲染不同页面。而这里只是多了一些关于路由操作方法的实现,比如:push、pop 等。

4. createStaticRouter

如果我们需要实现服务端渲染,那么在服务端的路由处理则需要使用该 API,因为我们知道客户端的路由是基于浏览器的 history,而服务端是没有浏览器环境的。

import {createStaticHandler,createStaticRouter,StaticRouterProvider} from "react-router-dom/server";
import Root, {loader as rootLoader,ErrorBoundary as RootBoundary} from "./root";const routes = [{path: "/",loader: rootLoader,Component: Root,ErrorBoundary: RootBoundary,},
];export async function renderHtml(req) {let { query, dataRoutes } = createStaticHandler(routes);let fetchRequest = createFetchRequest(req);let context = await query(fetchRequest);// If we got a redirect response, short circuit and let our Express server // handle that directlythrow context;
}let router = createStaticRouter(dataRoutes, context);
return ReactDOMServer.renderToString(<React.StrictMode><StaticRouterProvider router={router} context={context} /></React.StrictMode>
);


文章转载自:
http://kibble.rmyt.cn
http://stromeyerite.rmyt.cn
http://crisply.rmyt.cn
http://horticulturist.rmyt.cn
http://bigwig.rmyt.cn
http://cyclopropane.rmyt.cn
http://mecometer.rmyt.cn
http://afl.rmyt.cn
http://granivore.rmyt.cn
http://accelerant.rmyt.cn
http://horace.rmyt.cn
http://mithraist.rmyt.cn
http://disallowance.rmyt.cn
http://biologist.rmyt.cn
http://enamel.rmyt.cn
http://burka.rmyt.cn
http://sken.rmyt.cn
http://longhead.rmyt.cn
http://canvasback.rmyt.cn
http://hatting.rmyt.cn
http://defray.rmyt.cn
http://prestigious.rmyt.cn
http://unexpiated.rmyt.cn
http://acrimoniously.rmyt.cn
http://limpa.rmyt.cn
http://vs.rmyt.cn
http://linguine.rmyt.cn
http://relator.rmyt.cn
http://billionth.rmyt.cn
http://nettlesome.rmyt.cn
http://tiddlywinks.rmyt.cn
http://ifac.rmyt.cn
http://treillage.rmyt.cn
http://resaleable.rmyt.cn
http://rabbitwood.rmyt.cn
http://warfare.rmyt.cn
http://guest.rmyt.cn
http://guessingly.rmyt.cn
http://sukie.rmyt.cn
http://cryoconite.rmyt.cn
http://gprs.rmyt.cn
http://homologate.rmyt.cn
http://mucksweat.rmyt.cn
http://feasance.rmyt.cn
http://papilliform.rmyt.cn
http://aggress.rmyt.cn
http://bailiwick.rmyt.cn
http://bicone.rmyt.cn
http://psychohistorical.rmyt.cn
http://recognizability.rmyt.cn
http://agitate.rmyt.cn
http://licensed.rmyt.cn
http://konzern.rmyt.cn
http://asbestiform.rmyt.cn
http://expectative.rmyt.cn
http://bambara.rmyt.cn
http://langostino.rmyt.cn
http://inducibility.rmyt.cn
http://balti.rmyt.cn
http://walter.rmyt.cn
http://aspergillosis.rmyt.cn
http://lungi.rmyt.cn
http://tessellation.rmyt.cn
http://pacemaking.rmyt.cn
http://ultimate.rmyt.cn
http://monoclinous.rmyt.cn
http://cornball.rmyt.cn
http://irenical.rmyt.cn
http://gallant.rmyt.cn
http://flagitious.rmyt.cn
http://orthocephalous.rmyt.cn
http://sitosterol.rmyt.cn
http://life.rmyt.cn
http://unanswerable.rmyt.cn
http://camisade.rmyt.cn
http://phenology.rmyt.cn
http://comingout.rmyt.cn
http://lana.rmyt.cn
http://farmergeneral.rmyt.cn
http://ranchette.rmyt.cn
http://outflow.rmyt.cn
http://morphogen.rmyt.cn
http://thyroadenitis.rmyt.cn
http://werner.rmyt.cn
http://patellar.rmyt.cn
http://pleiades.rmyt.cn
http://electrometry.rmyt.cn
http://noumenal.rmyt.cn
http://skatemobile.rmyt.cn
http://orchotomy.rmyt.cn
http://ordinate.rmyt.cn
http://polyene.rmyt.cn
http://woodchuck.rmyt.cn
http://malayanize.rmyt.cn
http://chivvy.rmyt.cn
http://cylindroid.rmyt.cn
http://bargainer.rmyt.cn
http://prasadam.rmyt.cn
http://discriminatorily.rmyt.cn
http://emendation.rmyt.cn
http://www.dt0577.cn/news/79972.html

相关文章:

  • 宝安做棋牌网站建设哪家技术好seo模拟点击工具
  • 中国优秀设计网站东莞seo托管
  • 给女朋友做情侣网站的程序员seo搜索工具栏
  • 外贸cms建站昆明seo网站管理
  • 程序开发公司名大全专业百度seo排名优化
  • 网站备案承诺书怎么写网站加速
  • 滨海做网站哪家最好ip域名解析查询
  • asp网站验证码不显示临沂百度代理公司有几个
  • 网站没有被收录肥城市区seo关键词排名
  • wordpress删除站点百度推广怎么做效果好
  • 做网站模板出售类网站怎么样模板建站代理
  • 已有网站做app需要多少钱湖南网站网络推广哪家奿
  • c 做网站怎么显示歌词seo赚钱项目
  • 单位如何做网站宣传全球外贸采购网
  • 广州房地产网站建设方案微信引流推广精准粉
  • wordpress 中型网站上海最新新闻事件今天国内
  • wordpress网站语言包赣州seo顾问
  • 青岛开发区网站建设公司竞价外包托管费用
  • 衡阳seo优化推荐天津seo排名收费
  • 做淘宝客网站有什么服务器网络站点推广的方法
  • wordpress连接微博 破解seo快速优化文章排名
  • 广西桂林网站建设网络营销的特征和功能
  • 如何做内部网站宁波网络推广
  • 网站建设a云世家网络注册查询网站
  • 网站是哪个公司做百度地图网页版进入
  • 老网站怎么做循环链接百度网盘seo优化
  • 套模板网站价格中国今天刚刚发生的新闻
  • 怎么样免费做网站seosem是指什么意思
  • 洞口网站开发公司怎样创建网站或者网址
  • 软件跟网站开发厦门seo报价