现在有类似这样的代码
mui(document).on("tap", ".delete", function() {
console.log('mui(document).on("tap", ".delete")');
commentId = this.getAttribute('comment-id');
console.log(commentId);
deleteLetterComment(commentId);
});
我想把这里面的function提出来复用。我知道可以这么写
mui(document).on("tap", ".delete", beforeDeleteLetterComment);
function beforeDeleteLetterComment() {
console.log('mui(document).on("tap", ".delete")');
commentId = this.getAttribute('comment-id');
console.log(commentId);
deleteLetterComment(commentId);
}
然而还有一段代码需要传递参数
function beforesubmitComment(str)
{
}
我想也这样用,但是直接写mui(document).on("tap",".delete",beforesubmitComment(str));不生效
求助该怎么写。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
mui(document).on("tap",".delete",function() { beforesubmitComment(str); });
能想到的方法就是上面两位写的了,其他方法暂时不晓得
判断argument的长度,有就拿来用,没有就是默认空参