【发布时间】:2020-07-03 06:54:48
【问题描述】:
我像这样在 Sweetalert2 的页脚中创建了一个自定义按钮。
Swal.fire({
icon: "question",
showCancelButton: true,
confirmButtonColor: "#1976d2",
cancelButtonText: "No",
confirmButtonText: "Sí",
footer: "<button (click)='withoutread()' class='btn btn-info'>Test</button>"
})
withoutread() {
console.log('hello');
}
问题:withoutread 函数没有正确调用,console.log('hello') 没有在控制台中显示 hello。
那么:这段代码有什么问题?
【问题讨论】:
-
afaik (click) 是 Angular 语法,并且 Angular 不会重新编译代码,因此它不起作用。不确定普通的 js onclick 函数是否可以工作。
-
尝试将按钮放在锚标签
<a><button (click)='withoutread()' class='btn btn-info'>Test</button></a>
标签: angular sweetalert2