本文介绍了阻止 ActionSheet 在 Ionic 3 中关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Ionic 3 中有一个 ActionSheet,最后一个按钮用于显示更多选项.单击按钮时,应在 ActionSheet 上添加另外 2 个按钮.问题是当我单击任何按钮时,ActionSheet 正在关闭.我找不到阻止它关闭的方法.有什么方法可以阻止 ActionSheet 关闭?
I have an ActionSheet in Ionic 3 and the last button of that is for Displaying more option. When the button is clicked 2 more buttons should be added on the ActionSheet. The problem is when I clicked any button, the ActionSheet is getting closed. I could not find out a way to stop it from closing.Is there any way to stop ActionSheet from closing?
onMore(){
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Option 1',
handler: () => {
}
},
{
text: 'More',
handler: () => {
this.showMore(actionSheet);
}
}
]
});
actionSheet.present();
}
private showMore(actionSheet){
actionSheet.addButton({
text: 'Option 2',
handler: () => {
}
});
}
推荐答案
很简单.只需将 return false
添加到您的处理程序中,如下所示.
It is simple.Just add return false
to your handler like below.
onMore(){
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Option 1',
handler: () => {
}
},
{
text: 'More',
handler: () => {
this.showMore(actionSheet);
return false;
}
}
]
});
actionSheet.present();
}
这篇关于阻止 ActionSheet 在 Ionic 3 中关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!