如何使用 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() | ^^^^^^^