在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!");
这样就行了!!!
先写到这,有空排版。