我正在将我的一个项目迁移到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
使用扩容来部署我的React (用create-react-app创建),我得到以下错误。
2022-04-26T18:52:09.555Z [INFO]: Failed to parse source map from '/codebuild/output/src963792318/src/pn-toolbox-react/node_modules/react-bootstrap-sweetalert/src/components/Buttons.tsx' file: Error: ENOENT: no such file or directory, open '/c
我已经在我的项目中应用了sweetalert,我的应用程序是在景观方向和sweetalert全屏,我想设置自定义的宽度和高度为sweetalert。 SweetAlert.show(context,
title: "Just show a message",
subtitle: "Sweet alert is pretty",
style: SweetAlertStyle.confirm,
我使用将sweetalert2添加到rails 6应用程序中,但我得到了这个错误
Uncaught ReferenceError: Swal is not defined
我在environment.js文件中添加了以下代码
environment.plugins.append('Provide', new webpack.ProvidePlugin({
sweetalert2: 'sweetalert2/dist/sweetalert2.all',
Swal: 'sweetalert2/dist/sweetalert2.all'
}))
当循环运行时,我想显示一个加载甜蜜的警告。我怎么能让这一切成为可能。当前发生的情况是,甜警报只在循环结束后打开一秒钟。我尝试过创建testFunc异步,并等待等待函数,但这并没有帮助。现在不知道该怎么做。我很感谢你的帮助。非常感谢
function wait(ms) {
var start = new Date().getTime();
var end = start;
while (end < start + ms) {
end = new Date().getTime();
}
}
function testFunc() {
sweetAlert({
无论您单击"Confirm“或"Cancel",它们都会执行"isConfirm”和"Cancel“函数,因为它们不应该关闭警报。基本上,它似乎正在关闭和吞咽在确认函数中触发的SweetAlert。以前有人见过这个问题吗?
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton