android - 离子吐司 scss 类 - Angular - android
问题描述
我正在使用 Ionic 5、Angular 和 cordova。我有一个具有全局 toast 方法的服务提供商,代码如下:
GlobalToast(text: string) {
// creating a toast for global use throughout the app
this.toast = this.toastController.create({
message: text,
cssClass: 'my-toast-class',
animated: true,
duration: 370}).then((toastData) => {
toastData.present();
});
}
我在不同的组件中调用 toast,如下所示:
this.newFavAppService.GlobalToast(this.translate.instant('Favourites.Added'));
this.newFavAppService.GlobalToast(this.translate.instant('Favourites.Removed'));
我的 scss 是在 global.scss 文件中设置的,代码如下:
.md{
.my-toast-class{
--background: #000534 !important;
--color: white !important;
--width: max-content !important;
--height: 45px !important;
--border-radius: 200px !important;
position: sticky !important;
margin-bottom:12% !important;
text-align: center !important;
opacity: 87% !important;
top: 100% !important;
}
}
.ios{
.my-toast-class{
--background: #000534;
--color: white;
--width: max-content;
--height: 45px;
--border-radius: 200px;
position: sticky;
margin-bottom:10%;
text-align: center;
opacity: 0.83;
top: 100%;
}
}
Toast 适用于 ios(发布和调试版本),仅适用于 android 调试版本。一旦我构建了在 android 上发布的应用程序,吐司就不再出现了。我是否还可以补充一点,如果我删除 global.scss 类中的代码,则 toast 可以与开始时给出的基本 scss 一起使用。我认为这表明当我为在 android 中发布而构建时 global.scss 文件有问题。
请问有人有解决方案吗?
解决方案
constructor(public toastCtrl:ToastController) {}
async openToast() {
const toast = await this.toastCtrl.create({
message: 'LeaveType was Selected Successfully',
// position: 'middle',
duration: 3000
});
toast.present();
}
推荐阅读
- r - R Shiny-“renderDT”中的“容器”参数不允许通过“类”参数自定义表格样式类
- xcode - 如何查看一个类附加到哪个 viewController?
- pandas - 剪切和绘制数据框并重复
- windows - 带有引号的命令行参数的 Windows 快捷方式
- c# - C#一次更改所有按钮的背景颜色
- performance - 加载大量数据 - 允许的内存大小已用尽
- java - Swing Java 中带有多帧应用程序的任务栏图标
- git - git:检查现有文件的分支而不覆盖它们
- firebase - Firebase 控制台和 BigQuery 之间的差异
- python - PySide:文件夹的 TreeView 小部件