如何检查吐司是否存在
How to check if toast is present
我想检查 toast 是否存在,如果存在,我想移动购物车按钮
这里是现在的截图:
出现吐司时如何向上移动购物车按钮?甚至整个页面都要上移
我试过这个:
let toast = this.toastCtrl.create({
message: 'Dish added to Cart',
cssClass: 'mytoast',
duration: 2000
});
toast.onDidDismiss(() => {
console.log('Dismissed toast');
document.querySelector('.fab').setAttribute('bottom', '10px');
});
document.querySelector('.fab').setAttribute('bottom', '60px');
toast.present(toast);
});
但这不起作用
尝试:
(document.querySelector('.fab') as HTMLElement).style.bottom = '10px';
关闭并且
(document.querySelector('.fab') as HTMLElement).style.bottom = '60px';
创建时。
我只是忘记将样式传递给 setAttribute
所以这是答案:
let toast = this.toastCtrl.create({
message: 'Dish added to Cart',
cssClass: 'mytoast',
duration: 2000
});
toast.onDidDismiss(() => {
document.querySelector('.fab').setAttribute("style", "bottom: 10px;");
});
toast.present(toast);
document.querySelector('.fab').setAttribute('style','bottom:60px');
我想检查 toast 是否存在,如果存在,我想移动购物车按钮
这里是现在的截图:
出现吐司时如何向上移动购物车按钮?甚至整个页面都要上移
我试过这个:
let toast = this.toastCtrl.create({
message: 'Dish added to Cart',
cssClass: 'mytoast',
duration: 2000
});
toast.onDidDismiss(() => {
console.log('Dismissed toast');
document.querySelector('.fab').setAttribute('bottom', '10px');
});
document.querySelector('.fab').setAttribute('bottom', '60px');
toast.present(toast);
});
但这不起作用
尝试:
(document.querySelector('.fab') as HTMLElement).style.bottom = '10px';
关闭并且
(document.querySelector('.fab') as HTMLElement).style.bottom = '60px';
创建时。
我只是忘记将样式传递给 setAttribute
所以这是答案:
let toast = this.toastCtrl.create({
message: 'Dish added to Cart',
cssClass: 'mytoast',
duration: 2000
});
toast.onDidDismiss(() => {
document.querySelector('.fab').setAttribute("style", "bottom: 10px;");
});
toast.present(toast);
document.querySelector('.fab').setAttribute('style','bottom:60px');