【发布时间】:2017-11-14 05:53:31
【问题描述】:
我有一个按钮,我为该按钮定义了 onclick 属性的 doLogout 函数,但每次单击该按钮时都会显示以下错误:
Runtime Error function not defined - ReferenceError: function is not defined at HTMLButtonElement.onclick
代码很简单,我在其他页面用过,函数调用正确。这是我的 HTML 文件:
<ion-header>
<ion-navbar>
<ion-title>Logout</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<div padding>
<button ion-button block onclick="doLogout()">Logout</button>
</div>
</ion-content>
这是 ts 文件:
export class LogoutPage {
constructor(public navCtrl: NavController, public navParams: NavParams,
public api : Api) {
}
doLogout(){
//does something
}
}
【问题讨论】:
标签: html angular typescript ionic2 ionic3