如何在ionic2项目中使用iziToast? [英] How to use iziToast in ionic2 project?
问题描述
我有一个ionic2项目,现在我想在其中添加 iziToast 。我尝试按如下方式导入它:
I have a ionic2 project and now I want to add iziToast into it. I tried importing it like follows:
import { izitoast } from 'izitoast';
但它给了我 izitoast
as undefined。但是,我尝试搜索此库的angular2支持,我找到了 ng2-iziToast
它不能仅仅安装并将其导入app.module
But it gives me izitoast
as undefined. However, I tried searching for the angular2 support for this library and I found ng2-iziToast
It's not working just installing and importing it to the app.module
推荐答案
您正在尝试导入命名导出 izitoast
就像你习惯于Ionic / Angular一样(从'y'
导入{x})但izitoast不是建立在ES2015标准之上,这意味着我们必须像这样导入它:
You are trying to import a named export izitoast
like you are used to in Ionic/Angular (import { x } from 'y'
) but izitoast is not built on the ES2015 standard, which means we have to import it like this:
运行 npm install izitoast --save
import izitoast from 'izitoast';
并使用它:
izitoast.show(...);
查看离子 docs 。
这篇关于如何在ionic2项目中使用iziToast?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!