Giter VIP home page Giter VIP logo

Comments (12)

smallpath avatar smallpath commented on May 13, 2024

可以参考一下这一段

不局限于文章页面,所有页面都可以按这样的数据获取顺序,通过preFetch钩子来控制

from blog.

willis325 avatar willis325 commented on May 13, 2024

博主,为啥我在生产环境下F12还能看到请求呢

from blog.

smallpath avatar smallpath commented on May 13, 2024

你是说哪个请求啊? 博客刷新的话没有Ajax异步请求和分块加载请求,文章页的请求大多数是disqus评论

from blog.

willis325 avatar willis325 commented on May 13, 2024

就是博客刷新的時候會出現類似ajax請求

from blog.

smallpath avatar smallpath commented on May 13, 2024

纳尼,你截个图看看?

from blog.

willis325 avatar willis325 commented on May 13, 2024

image

from blog.

smallpath avatar smallpath commented on May 13, 2024

哦,去除Ajax请求是SSR做的,你需要把它改成SSR形式

from blog.

willis325 avatar willis325 commented on May 13, 2024

是ssr啊

from blog.

willis325 avatar willis325 commented on May 13, 2024

博主 从首页进入文章页 为什么我的页面不是先把数据渲染完 再渲染页面啊

from blog.

smallpath avatar smallpath commented on May 13, 2024

官方路由的数据获取是这样的,分为两种模式,根据SSR的特征,在导航完成前获取数据可以充分利用preFetch钩子,因此我觉得更好一些。

详细的描述在这一节

from blog.

willis325 avatar willis325 commented on May 13, 2024

博主 你上面说的这种方法 在导航完成前preFetch 但是在server-entry的时候也会preFetch 那么第一次加载的时候会出现两次preFetch 这个怎么解决呢

from blog.

smallpath avatar smallpath commented on May 13, 2024

导航完成前的preFetch是用router.beforeEach等钩子来做的吧?把他们放到store.replaceState(window.__INITIAL_STATE__)语句之后,首屏就不会再次触发preFetch了。原因是使用了vue-router-sync,替换全局状态中的route属性时会触发一次路由钩子

from blog.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.