当前位置:网站首页>vus. Precautions for SSR requesting data in asyndata function

vus. Precautions for SSR requesting data in asyndata function

2022-07-07 07:37:00 Attacking-Coder

Abstract

If you need to request data during server rendering, you cannot use mouted Request in life cycle , This is because mouted The request will not be sent until all component instances are hung on the page , Such a request is actually completed on the client side, which is not conducive to SEO. And we're doing it SSR The original intention is to speed up the loading of the first screen , Another is for SEO( Crawled by reptiles ),
So we're going to be here asynData Execute in the declaration cycle

Be careful

  1. If the page is refreshed asynData The request of is completed on the server
  2. If the page is jumped in by other pages, then asynData My request is in The client finished

explain : Why is the request completed on the client when entering from other pages ?

This is because the crawler will not click from a page to enter the page , It will only directly enter the designated URL So this will not affect SEO
Secondly SSR It is mainly to solve the problem of slow loading of the first screen , Then it's definitely not your first screen to jump in

原网站

版权声明
本文为[Attacking-Coder]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070404001357.html