gpt4 book ai didi

angular - SweetAlert 与 Angular 7

转载 作者:行者123 更新时间:2023-12-03 18:37:17 25 4
gpt4 key购买 nike

我正在尝试在我的 angular 项目中使用甜蜜警报。

这就是我使用甜蜜警报的方式:

import swal from 'sweetalert';

swal({
title: "Problem",
text: "Try again later!",
icon: "error"
})

我收到以下错误:

ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must be of type 'typeof import("C:/Users/user/Desktop/University/Thesis/workspace/web/myProject/project/node_modules/sweetalert/typings/sweetalert")', but here has type 'SweetAlert'.



任何人都可以帮助我吗?

最佳答案

编译Angular项目的简单解决方案是
转到您的项目文件夹
\node_modules\sweetalert\typings\sweetalert.d.ts

在此文件中只需注释该行
//const swal: SweetAlert;

您的最终文件如下所示:

import swal, { SweetAlert } from "./core";

declare global {
// const swal: SweetAlert;
const sweetAlert: SweetAlert;
}

export default swal;
export as namespace swal;

关于angular - SweetAlert 与 Angular 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54889000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com