我试图用我正在编写的方法访问我的数据,但它似乎不起作用。我收到 TS2339 Typescript 错误,指出类型中不存在该属性。
TS2339: Property 'players' does not exist on type '{ onAddPlayers(): void; getPlayerPlaceholder(index: number): string; }'.
47 | methods: {
48 | onAddPlayers() {
> 49 | this.games = prepareGames(this.players as PadelPlayer[]);
| ^^^^^^^
50 | },
51 | getPlayerPlaceholder(index: number) {
52 | const playerNumber = Number(index) + 1;
这是该组件的代码:
<script>
import { PadelGame } from "@/models/padelGame.interface";
import { getPadelPlayers, prepareGames } from "../services/americanoService";
import { PadelPlayer } from "@/models/padelPlayer.interface";
const padelGames: PadelGame[] = [];
export default {
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>
aluckdog
相关分类