0

我正在使用带有nuxtjs的 locomotive-scroll并在更改路线时获得了一些有线行为。在每次页面开始时更改路线后,我离开滚动我的上一页。我尝试了 nuxt scrollBehavior 功能,该功能无需使用机车滚动即可正常工作。

下面是我放在default.vue文件中的代码

@Watch('$route')
  handleRouteChange(route: any, oldRoute: any) {
    this.$nuxt.$emit('update-locomotive');
  }

  mounted() {
    this.$nuxt.$on('update-locomotive', () => {
      (this as any).$refs.scroller.locomotive?.update();
    });

    if (process.browser && window) {
      this.retrieveCredential();
    }
  }

我正在观察路线变化和更新机车。

提前致谢

4

0 回答 0