1、引入组件
import { ActionSheetController } from 'ionic-angular';
2、声明组件
public actionSheetCtrl: ActionSheetController
3、定义操作表组件函数
presentActionSheet() {
//定义操作表
const actionSheet = this.actionSheetCtrl.create({
title: 'Modify your album',//操作表标题
buttons: [
{
text: 'Destructive',//按钮文字
role: 'destructive',//按钮属性
handler: () => {//回调事件
console.log('Destructive clicked');
}
},{
text: 'Archive',
handler: () => {
console.log('Archive clicked');
}
},{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
//创建(使用)操作表
actionSheet.present();
}
4、视图层绑定函数presentActionSheet()