gpt4 book ai didi

windows - 运行时错误 : Cannot read property 'push' of undefined

转载 作者:可可西里 更新时间:2023-11-01 10:33:05 26 4
gpt4 key购买 nike

我收到无法读取 ionic2 中未定义属性 'push' 的错误

addReview(){

let modal = this.modalCtrl.create(AddReviewPage);

modal.onDidDismiss(review => {
if(review){
this.reviews.push(review);
this.reviewService.createReview(review);
}
});

最佳答案

您只需声明初始化您的reviews数组,如下所示。

export class YourPage {

reviews:any=[];//here is the place

constructor(){}

addReview(){
let modal = this.modalCtrl.create(AddReviewPage);
modal.onDidDismiss(review => {
if(review){
this.reviews.push(review);
this.reviewService.createReview(review);
}
});
}

关于windows - 运行时错误 : Cannot read property 'push' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42968943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com