gpt4 book ai didi

javascript - 错误 : Uncaught (in promise): TypeError: Cannot read property 'title' of undefined

转载 作者:搜寻专家 更新时间:2023-10-30 21:22:38 30 4
gpt4 key购买 nike

html文件

<ion-header>
<ion-toolbar color="danger">
<ion-buttons>
<button ion-button navPop icon-only>
<ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon>
</button>
</ion-buttons>
<ion-title text-wrap>志愿者评选</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<h1>{{volunteer.title}}</h1><br/>
</ion-content>

ts 文件

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';


@Component({
selector: 'page-volunteer-vote-detail',
templateUrl: 'volunteer-vote-detail.html',
})

export class VolunteerVoteDetailPage {
volunteer:any;

constructor(public navCtrl: NavController, public navParams: NavParams) {
this.volunteer = navParams.get('volunteer');
}

}

在其他页面,我使用this.volunteer = navParams.get('volunteer');获取数据,但是这里无法获取数据并显示错误

错误:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'title' of undefined TypeError: Cannot read property 'title' of undefined at Object.eval [as updateRenderer] (VM3975 VolunteerVoteDetailPage.ngfactory.js:64) at Object.debugUpdateRenderer [as updateRenderer] (VM3846 vendor.js:14729) at checkAndUpdateView (VM3846 vendor.js:13865) at callViewAction (VM3846 vendor.js:14210) at execComponentViewsAction (VM3846 vendor.js:14142) at checkAndUpdateView (VM3846 vendor.js:13866) at callWithDebugContext (VM3846 vendor.js:15092) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (VM3846 vendor.js:14629) at ViewRef_.detectChanges (VM3846 vendor.js:11652) at Tab.NavControllerBase.viewAttachToDOM (VM3846 vendor.js:49817) at Object.eval [as updateRenderer] (VM3975 VolunteerVoteDetailPage.ngfactory.js:64) at Object.debugUpdateRenderer [as updateRenderer] (VM3846 vendor.js:14729) at checkAndUpdateView (VM3846 vendor.js:13865) at callViewAction (VM3846 vendor.js:14210) at execComponentViewsAction (VM3846 vendor.js:14142) at checkAndUpdateView (VM3846 vendor.js:13866) at callWithDebugContext (VM3846 vendor.js:15092) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (VM3846 vendor.js:14629) at ViewRef.detectChanges (VM3846 vendor.js:11652) at Tab.NavControllerBase._viewAttachToDOM (VM3846 vendor.js:49817) at c (VM3844 polyfills.js:3) at Object.reject (VM3844 polyfills.js:3) at Tab.NavControllerBase._fireError (VM3846 vendor.js:49580) at Tab.NavControllerBase._failed (VM3846 vendor.js:49573) at VM3846 vendor.js:49620 at t.invoke (VM3844 polyfills.js:3) at Object.onInvoke (VM3846 vendor.js:4979) at t.invoke (VM3844 polyfills.js:3) at r.run (VM3844 polyfills.js:3) at VM3844 polyfills.js:3

编辑:

enter image description here

更新:

ts 文件

goToVolunteerVoteDetail(volunteerItem:any) {
this.navCtrl.push(VolunteerVoteDetailPage,{
volunteer:volunteerItem
});
}

html文件

(click)="goToVolunteerVoteDetail(volunteer)"

最佳答案

变量volunteer 似乎未定义。这是由于行中的错误:

this.volunteer = navParams.get('volunteer');

显然您没有发送名为 volunteer 的参数。因此 navParams 是空的。我的建议是去你推送(或路由)的任何页面并像这样使用 navcontroller:

this.navCtrl.push(VolunteerVoteDetailPage, {
volunteer: "yourDATA"
});

关于javascript - 错误 : Uncaught (in promise): TypeError: Cannot read property 'title' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47788447/

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