1 回答

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊
defineComponent要獲得類型推斷,您應(yīng)該使用從 vue 導(dǎo)入來創(chuàng)建組件實(shí)例:
<script>
import { PadelGame } from "@/models/padelGame.interface";
import { getPadelPlayers, prepareGames } from "../services/americanoService";
import { PadelPlayer } from "@/models/padelPlayer.interface";
import {defineComponent} from 'vue'
const padelGames: PadelGame[] = [];
export default defineComponent({
data() {
return {
players: getPadelPlayers(),
games: padelGames,
};
},
methods: {
onAddPlayers() {
this.games = prepareGames(this.players as PadelPlayer[]);
},
getPlayerPlaceholder(index: number) {
const playerNumber = Number(index) + 1;
return "Spelare " + playerNumber;
},
},
});
</script>
添加回答
舉報(bào)