我正试图在我的棱角分明的项目中使用甜蜜的警告。
这就是我如何使用甜蜜的警告:
import swal from 'sweetalert';
swal({
title: "Problem",
text: "Try again later!",
icon: "error"
})
我得到以下错误:
node_modules/sweetalert/typings/sweetalert.d.ts(4,9):ERROR TS2403中的错误:后续变量声明必须具有相同的类型。变量'swal‘必须是’type of import("C:/Users/user/Desktop/University/Thesis/workspace/web/myProject/project/node_modules/sweetalert/typings/sweetalert")',‘,但是这里有'SweetAlert’类型。
有人能帮我吗?
发布于 2019-07-09 21:02:19
我也有同样的问题,我的解决办法就是这个。
import * as _swal from 'sweetalert';
import { SweetAlert } from 'sweetalert/typings/core';
const swal: SweetAlert = _swal as any;
由于某些原因,名称"swal“显示错误,如果您将别名更改为"_swal”,它应该会工作。
https://stackoverflow.com/questions/54889000
复制相似问题