ssr next原理_查看源代码以确认SSR在Next.js中正常工作

ssr next原理

Do you have set up your new Next.js application? Great!

您是否已设置新的Next.js应用程序? 大!

Let’s now check the application is working as we expect it to work. It’s a Next.js app, so it should be server side rendered.

现在让我们检查应用程序是否正常运行。 这是一个Next.js应用程序,因此应该在服务器端呈现

It’s one of the main selling points of Next.js: if we create a site using Next.js, the site pages are rendered on the server, which delivers HTML to the browser.

这是Next.js的主要卖点之一:如果我们使用Next.js创建一个站点,则站点页面将呈现在服务器上,该服务器会将HTML传递给浏览器。

This has 3 major benefits:

这具有3个主要优点:

  • The client does not need to instantiate React to render, which makes the site faster to your users.

    客户端不需要实例化React来渲染,这使得网站对您的用户更快。
  • Search engines will index the pages without needing to run the client-side JavaScript. Something Google started doing, but openly admitted to be a slower process (and you should help Google as much as possible, if you want to rank well.

    搜索引擎将为页面编制索引,而无需运行客户端JavaScript。 Google开始做的事情,但公开承认这是一个缓慢的过程(如果您想获得良好的排名,则应该尽可能地帮助Google。
  • You can have social media meta tags, useful to add preview images, customize title and description for any of your pages shared on Facebook, Twitter and so on.

    您可以拥有社交媒体元标记,可用于添加预览图像,自定义在Facebook,Twitter等上共享的任何页面的标题和描述。

Let’s view the source of the app. Using Chrome you can right-click anywhere in the page, and press View Page Source.

让我们查看应用程序的源代码。 使用Chrome,您可以右键单击页面中的任意位置,然后按查看页面源

If you view the source of the page, you’ll see the <div><h1>Airbnb clone</h1></div> snippet in the HTML body, along with a bunch of JavaScript files - the app bundles.

如果您查看页面的源代码,则会在HTML body看到<div><h1>Airbnb clone</h1></div>片段,以及一堆JavaScript文件-该应用程序捆绑。

We don’t need to set up anything, SSR (server-side rendering) is already working for us.

我们不需要进行任何设置,SSR(服务器端渲染)已经为我们工作。

The React app will be launched on the client, and will be the one powering interactions like clicking a link, using client-side rendering. But reloading a page will re-load it from the server. And using Next.js there should be no difference in the result inside the browser - a server-rendered page should look exactly like a client-rendered page.

React应用程序将在客户端上启动,并且将成为使用客户端渲染推动交互的一种方式,例如单击链接。 但是重新加载页面会从服务器重新加载页面。 使用Next.js,浏览器内部的结果应该没有差异-服务器呈现的页面应该看起来完全像客户端呈现的页面。

翻译自: https://flaviocopes.com/nextjs-ssr/

ssr next原理

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 MATLAB ,可以使用 `ncread` 函数读取 NetCDF 文件的变量数据,并使用掩模(mask)来选择或过滤数据。掩模是一个逻辑数组,其的 true 值表示要选择或保留的数据,false 值表示要过滤掉的数据。对于一个 NetCDF 文件,通常会包含一个名为 `lat` 和一个名为 `lon` 的变量,用于描述数据在纬度和经度方向上的位置。可以使用这些变量来创建一个掩模,以过滤掉陆地数据。 以下是对 `uv_ssr.nc` 文件的海洋数据进行选择和处理的示例代码: ``` % 读取 NetCDF 文件的纬度、经度和 SSR 变量数据 lat = ncread('uv_ssr.nc', 'lat'); lon = ncread('uv_ssr.nc', 'lon'); ssr = ncread('uv_ssr.nc', 'ssr'); % 创建一个掩模,以过滤掉陆地数据 oceanMask = isnan(ssr); for i = 1:size(ssr, 1) for j = 1:size(ssr, 2) if isnan(ssr(i, j)) oceanMask(i, j) = true; elseif ~isnan(ssr(i, j)) && (lat(i, j) > 70 || lat(i, j) < -70 || ... lon(i, j) > 180 || lon(i, j) < -180) oceanMask(i, j) = false; end end end % 将陆地数据设置为 NaN ssr(oceanMask == false) = NaN; % 可以使用 ssr 变量的海洋数据进行后续分析 ``` 在这个示例代码,我们首先使用 `ncread` 函数读取了纬度、经度和 SSR 变量的数据。然后,我们创建了一个 `oceanMask` 控制变量,初始化为所有位置都是 false。通过遍历数据,将所有的 NaN 值设置为 true,并将纬度和经度超出海洋范围的值设置为 false。最后,我们将 `oceanMask` 为 false 的位置的 SSR 数据设置为 NaN,以过滤掉陆地数据。 注意,这只是一个示例代码,实际情况下,需要根据具体的数据情况和需要进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值