如何在打字稿中使用 Nuxt fetch() 钩子?

时间:2021-06-23 21:20:47

标签: nuxt.js

如何使用 fetch 钩子?

脚本有效,但打字稿编译器报告错误。

<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'
@Component({
  components: {ValidationProvider, ValidationObserver},
  async fetch() {
    const winnerProcessService = new WinnerProcessService(this.$route)
    this.winner = await winnerProcessService.findWinner()
  }
})
export default class winPayClient extends Vue {
  winner: Winner = winnerInitialiser

Typescript 设置为严格

ERROR  ERROR in client/pages/index.vue:163:10                                                                                                                       
07:14:11
TS2339: Property 'winner' does not exist on type 'Vue'.
161 |     console.log(this.$route);
162 |     const winnerProcessService = new WinnerProcessService(this.$route)
<块引用>

163 | this.winner = await WinnerProcessService.findWinner() | ^^^^^^^

0 个答案:

没有答案