How to use iziToast in ionic2 project?

柔情痞子 提交于 2019-12-11 15:34:28

问题


I have a ionic2 project and now I want to add iziToast into it. I tried importing it like follows:

import { izitoast } from 'izitoast';

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


回答1:


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:

After running npm install izitoast --save

import izitoast from 'izitoast';

and to use it:

izitoast.show(...);

Check out the ionic docs on how to work with 3rd party libs.



来源:https://stackoverflow.com/questions/46042890/how-to-use-izitoast-in-ionic2-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!