微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SweetAlert Basic 安装不起作用

如何解决SweetAlert Basic 安装不起作用

我在 angular 中创建了一个新项目并安装了 SweetAlert 在构建项目时,我收到以下错误

enter image description here

我按照这里的步骤操作: https://sweetalert.js.org/guides/#installation

import { Component,OnInit } from "@angular/core";
import swal  from  'sweetalert'


@Component({
    templateUrl:'./inactive.component.html'
})
export class InactiveComponent implements OnInit{

    constructor(){

    }

    clickme(){
        swal("HelloWorld");
    }

    ngOnInit(){
        
    }
}

我已经尝试了互联网上的解决方案。没有什么对我有用。我无法在 node_modules 中进行更改。有没有其他解决方法

编辑: 我试过这个,但同样的错误

import { Component,OnInit } from "@angular/core";
import * as _swal  from  'sweetalert';
import {SweetAlert} from'sweetalert/typings/core'


@Component({
    templateUrl:'./inactive.component.html'
})
export class InactiveComponent implements OnInit{

    isLoading:boolean = true;
    constructor(){

    }

    clickme(){
        const swal:SweetAlert = _swal as any;
        swal("T popup")
    }

    ngOnInit(){
        
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。