quasar里Loading plugin造成scrollBehavior的行为不正确

发布时间 2023-06-16 18:40:16作者: zjhgx

发现线上的项目页面scrollBehavior表现不正常。从Index点击route到detail页面,再后退,回到的位置是detail页面的scroll position,而不是route前index页面的scroll position。后来到以前的分支查看,发现是在ssr改造后出现的问题。一开始以为是quasar.conf.js 的preFetch: true开关的问题。把开关关闭就好了,后来发现是在DetailPage的preFetch hook中使用了Loading plugin的关系。后来查到有人也遇到这个问题。改成Loading只在server端使用。

https://forum.quasar-framework.org/topic/5934/scroll-behaviour-when-using-prefetch-ssr/3

I noticed they are using preventScroll in the Loading.js file and this is apparently the bug source, when I removed it to test, the scrolling worked as expected