0

我很困惑,用谷歌搜索了很多,但没有找到答案。无论我尝试什么,以下代码都会导致: Uncaught TypeError: $(...).editRule is not a function。

    functionName(){
         [...]    
         $(`#index`).unbind().click(() => {
            $(`#index`).editRule(rule);
          });
      }

      editRule (rule) {
        // do sth
      }

参考肯定有效。其他预定义函数,如 .remove() 行为正确。我尝试了很多(函数或静态,无参数,其他函数等),但错误仍然存​​在,我对点击事件不是很有经验。有人知道问题是什么吗?

4

1 回答 1

0

您是否editRule使用以下方法将方法添加到 jQuery:https ://api.jquery.com/jquery.fn.extend/ ?或者你正在使用一个特殊的 jQuery 库来添加editRule到 jQuery 的方法中?

否则editrule不是 jQuery 方法,不能像这样链接。

于 2018-05-17T20:28:29.090 回答