美文网首页
在Angular中使用sweetalert 插件报错:ERROR

在Angular中使用sweetalert 插件报错:ERROR

作者: D_Wang | 来源:发表于2019-01-18 21:04 被阅读0次

在Angular中使用sweetalert 插件时报错:ERROR TypeError: sweetalert_1.default is not a function的解决办法:
报错如图


image.png

sweetalert 官网:https://sweetalert.js.org/guides/
当按照官网提示安装: npm install sweetalert --save,
导入:import swal from 'sweetalert';
使用:swal("Hello world!");

有可能会报如上的错误;

解决办法:
导入:
import * as _swal from 'sweetalert';
import { SweetAlert } from 'sweetalert/typings/core';
const swal: SweetAlert = _swal as any;

使用:swal("Hello world!");

这样就行了!!!

先写到这,有空排版。

相关文章

网友评论

      本文标题:在Angular中使用sweetalert 插件报错:ERROR

      本文链接:https://www.haomeiwen.com/subject/fvsodqtx.html