在Angular中使用sweetalert 插件時報錯:ERROR TypeError: sweetalert_1.default is not a function的解決辦法:
報錯如圖
image.png
sweetalert 官網(wǎng):https://sweetalert.js.org/guides/
當按照官網(wǎng)提示安裝: npm install sweetalert --save留晚,
導(dǎo)入:import swal from 'sweetalert';
使用:swal("Hello world!");
有可能會報如上的錯誤由境;
解決辦法:
導(dǎo)入:
import * as _swal from 'sweetalert';
import { SweetAlert } from 'sweetalert/typings/core';
const swal: SweetAlert = _swal as any;
使用:swal("Hello world!");
這樣就行了T兰稀RТ蕖!
先寫到這,有空排版懂讯。