我正在将我的一个项目迁移到TypeScript,在该项目中使用了库。
导入SweetAlert2 ( JS和CSS)的默认方法是
import Swal from 'sweetalert2'
这在TypeScript中很好,因为库中有类型:
但在我的项目中,导入的方式是:
import Swal from 'sweetalert2/dist/sweetalert2.js'
这是只对JS重要的,没有样式。对于这种类型的导入,我得到了TS错误:
Could not find a declaration file for module 'sweetalert2
无论您单击"Confirm“或"Cancel",它们都会执行"isConfirm”和"Cancel“函数,因为它们不应该关闭警报。基本上,它似乎正在关闭和吞咽在确认函数中触发的SweetAlert。以前有人见过这个问题吗?
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton
我一直在努力解决AngularJS的问题。我想加载自定义组件,然后调用它们的函数,但没有找到一种方法。
在下面的代码中,我尝试在项目成功发布后显示SweetAlert ()。
函数配置($stateProvider,$urlRouterProvider,$ocLazyLoadProvider) { $urlRouterProvider.otherwise("/index/main");
$ocLazyLoadProvider.config({
// Set to true if you want to see what and when is dynamically l
我正在关注,它正在创造奇迹。但是,使用iconColor属性时,我在控制台中得到以下错误:SweetAlert2: Unknown parameter "iconColor"。如何轻松更改图标的颜色?我可以使用customClass更改颜色,但我更喜欢使用文档中所示的iconColor。
Javascript:
function Delete(e) {
swal.fire({
title: "Do you want to delete?",
text: " You
在角度项目中npm启动后,得到了这个错误。
(12,7):错误TS2304:无法找到名称'swal‘。app(21,7):错误TS2304:无法找到名称'swal‘。
我创造了一个棱角分明的项目。在app.component.ts内部,我添加了甜蜜的警报代码
export class AppComponent {
deleteRow() {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",