我正在尝试测试所有 Ionic 2 组件,但我不知道如何使用操作表。
我有这个代码:
actionSheet.html:
<button (click)="showActionSheet()">Show Actionsheet</button>
actionSheet.js:
import {Page, NavController} from 'ionic/ionic';
import {ActionSheet} from 'ionic/ionic';
@Page({
templateUrl: 'app/actionSheet/actionSheet.html'
})
export class ActionSheetPage {
constructor(nav: NavController) {
this.nav = nav;
}
showActionSheet() {
ActionSheet.open({
buttons: [
{ text: 'Share This' },
{ text: 'Move' }
],
destructiveText: 'Delete',
titleText: 'Modify your album',
cancelText: 'Cancel',
cancel: () => {
console.log('Canceled');
},
destructiveButtonClicked: () => {
console.log('Destructive clicked');
},
buttonClicked: (index) => {
console.log('Button clicked: ', index);
}
}).then(actionSheetRef => {
// Action sheet was created and opened
this.actionSheetRef = actionSheetRef;
// this.actionSheetRef.close() to close it
})
}
}
当我单击按钮时,出现此错误:
19 010801 错误例外:评估“点击”时出错 20 010804 错误原始例外:TypeError:ionic_2.ActionSheet.open 不是函数 21 010806 错误 ORIGINAL STACKTRACE:22 010808 错误 TypeError:ionic_2.ActionSheet.open 不是函数
一些小费?