我是一名新的ecmaScript6学生。我需要在封装库函数时链接到“然后” promise。Swal是sweetAlert2函数,用于提问并获得用户的答复,是/否。]
这是我想做的;
class MyLib { constructor() { } static askQuestion(title, message){ Swal.fire({ title: title, text: message, showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!' }).then((result) => { return result; }) } }
然后将该函数称为;
)而给我“ .askQuestion(...)未定义”。MyLib.askQuestion("Are you sure?", "Are you sure you want to delete this ?").then(alert(result));
但是当然;在运行时控制台上,由于警报(result
如何链接两个然后在es6中起作用?
我是一名新的ecmaScript6学生。我需要在封装库函数时链接到“然后” promise。 Swal是sweetAlert2函数,用于询问问题并获得用户的答复,是/否。这是...
您需要兑现您的承诺: