在执行SvelteKit表单操作之前,我请求用户进行确认。我有一个自定义提交功能,它执行默认的操作逻辑,以防确认
returns
true:
const submit: SubmitFunction = async ({ cancel }) => {
if (confirm("Are you sure you want to delete this post?")) {
return async ({ update }) => {
return update();
};
} else {
cancel();
}
};
上面的代码
作品
,但我也尝试了以下操作:
const submit: SubmitFunction = async ({ cancel }) => {
if (confirm("Are you sure you want to delete this post?")) {
return async ({ result }) => {
return await applyAction(result);
};
} else {
cancel();
}
};
它似乎也在做同样的事情。这两个片段在行为方面有什么不同吗?是否出于技术原因而推荐其中一个?