gpt4 book ai didi

angular - 点击事件无效, "co.console.log() is not a function"

转载 作者:太空狗 更新时间:2023-10-29 18:05:55 25 4
gpt4 key购买 nike

我一直在尝试让一个按钮工作以调出一个页面,在参数中传递一个对象,但由于某种原因,它给了我错误

"co. is not a function."

我不知道问题出在哪里,因为当我尝试使用 alertconsole.log 或其他任何东西时,它给了我同样的错误。

页面 HTML:

<ion-header>

<ion-navbar>
<ion-title>SearchResults</ion-title>
</ion-navbar>

</ion-header>


<ion-content padding>
<ion-list>
<ion-item *ngFor= "let item of resultArray;">
<img src={{item.thumbnail}} />
<p>{{item.title}}</p>
<button bookDetail (click)="console.log(\"Even some text, please?\")">DETAIL</button>
</ion-item>
</ion-list>
</ion-content>

最佳答案

在您的 ts 文件中,只需执行以下操作即可。

.ts

log():void {
console.log('Your message here');
}

html

<button ion-button (click)="log()">DETAIL</button>

注意:如果您需要传递item,那么只需在html 上执行log(item) > 端和 tslog(data):void {}

关于angular - 点击事件无效, "co.console.log() is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43429938/

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