我收到錯誤:樓盤X上不存在類型Y []
questions does not exist on type 'Quiz[]'
這是我的模型
export interface Quiz {
$key ?: string;
categorie ?: string;
questions : Questions[]
}
export interface Questions {
id ?: number;
question ?: string;
answer?: string;
}
這是我的代碼
import {Quiz} from "../models/quiz";
export class ProfComponent {
quiz = [] as Quiz[];
nextQuestion(quiz) {
this.quiz.questions.push(quiz.questions)
}
}
我不能將數據推入quiz.questions
什麼可能是錯的?
異步nextQuestion(測驗){ 等待this.quiz.push(測驗) } – Afnor