如何在Ionic 2中定义一个函数 [英] How to define a function in Ionic 2
本文介绍了如何在Ionic 2中定义一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在Ionic 2中定义一个简单的函数。这是我的代码:
I cannot define a simple function in Ionic 2. This is my code:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
@Component({
selector: 'page-account',
templateUrl: 'account.html'
})
export class AccountPage {
function show() //←THIS FUNCTION
{
alert("show");
}
constructor(public navCtrl: NavController, public navParams: NavParams) {}
}
然后这是网络浏览器中的错误:
then this is the error in the web browser:
我正在使用离子2.2.0。
I'm using ionic 2.2.0.
感谢您的帮助。
推荐答案
删除函数
只需输入您的代码:
show() //Return type would be `show(): string` f.e.
{
alert("show");
}
这篇关于如何在Ionic 2中定义一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文