javascript sweetalert 2-如何显示加载动画图标

gcuhipw9  于 2023-03-11  发布在  Java
关注(0)|答案(1)|浏览(261)

我正在使用sweetalert2的警报消息。下面是我的代码:

this.$swal({                        
    icon: 'warning',
    html: 'Please be patient, it can take up to several minutes to generate a test.',
    showCloseButton: false,
    showCancelButton: true,
    showConfirmButton: false,
    allowOutsideClick : false, 
    focusConfirm: false,                        
    cancelButtonText : 'Cancel Test',
    customClass: {
        confirmButton: 'btn btn-primary',
        cancelButton: 'btn btn-outline-danger ml-1',
    },
    buttonsStyling: false,
}).then(( result ) => {
    if( result.isDismissed ) {
        this.isTestStop = true;
    }                        
});

输出为:

如您所见,图标为警报图标,但如何在此处显示加载图标?

qyuhtwio

qyuhtwio1#

删除icon属性,并将图像添加到html中。

this.$swal({                        

    html: '<div><img src="my-loading-icon.gif" /></div><div>Please be patient, it can take up to several minutes to generate a test.</div>',
    showCloseButton: false,
    showCancelButton: true,
    showConfirmButton: false,
    allowOutsideClick : false, 
    focusConfirm: false,                        
    cancelButtonText : 'Cancel Test',
    customClass: {
        confirmButton: 'btn btn-primary',
        cancelButton: 'btn btn-outline-danger ml-1',
    },
    buttonsStyling: false,
}).then(( result ) => {
    if( result.isDismissed ) {
        this.isTestStop = true;
    }                        
})

;

相关问题