为了账号安全,请及时绑定邮箱和手机立即绑定

想把JS的匿名函数改为普通函数,求助如何传递参数

想把JS的匿名函数改为普通函数,求助如何传递参数

慕少森 2018-08-17 14:09:07
现在有类似这样的代码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));不生效求助该怎么写。
查看完整描述

1 回答

?
三国纷争

TA贡献1804条经验 获得超7个赞

mui(document).on("tap",".delete",function(){
    beforesubmitComment(str)
});


查看完整回答
反对 回复 2018-09-19
  • 1 回答
  • 0 关注
  • 990 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信