Vue3 + 类组件 + Typescript:如何在使用面向 Vue 的装饰器时使用 beforeRouteEnter

问题描述 投票:0回答:1

我试图在 VUE3 类组件中调用 beforeRouteEnter 函数。我尝试使用组件修饰符并将函数放在类中,但它们都不起作用。

<template>
  <div>
    ...
  </div>
</template>

<script lang="ts">
  import { Vue, Component } from 'vue-class-component';
  @Component({
   modifier: (options) => {
    options.beforeRouteEnter = (to, from, next) {
      // do something
    }
   }
  })
  export default class HelloWorld extends Vue {
   // or try to place the router function here
   beforeRouteEnter(to, from, next) {
    // do something

   }

  }
</script>

那么我应该怎么做才能在 vue-faceing-decorator 中调用路由器钩子

vuejs3 vue-router vue-class-components
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.