<legend id='FQIqZ'><style id='FQIqZ'><dir id='FQIqZ'><q id='FQIqZ'></q></dir></style></legend>
      1. <i id='FQIqZ'><tr id='FQIqZ'><dt id='FQIqZ'><q id='FQIqZ'><span id='FQIqZ'><b id='FQIqZ'><form id='FQIqZ'><ins id='FQIqZ'></ins><ul id='FQIqZ'></ul><sub id='FQIqZ'></sub></form><legend id='FQIqZ'></legend><bdo id='FQIqZ'><pre id='FQIqZ'><center id='FQIqZ'></center></pre></bdo></b><th id='FQIqZ'></th></span></q></dt></tr></i><div id='FQIqZ'><tfoot id='FQIqZ'></tfoot><dl id='FQIqZ'><fieldset id='FQIqZ'></fieldset></dl></div>
        • <bdo id='FQIqZ'></bdo><ul id='FQIqZ'></ul>
        <tfoot id='FQIqZ'></tfoot>

      2. <small id='FQIqZ'></small><noframes id='FQIqZ'>

        如何在 Chrome 扩展中删除事件监听器

        时间:2023-09-04
        • <bdo id='rqR1K'></bdo><ul id='rqR1K'></ul>
          <legend id='rqR1K'><style id='rqR1K'><dir id='rqR1K'><q id='rqR1K'></q></dir></style></legend>
        • <i id='rqR1K'><tr id='rqR1K'><dt id='rqR1K'><q id='rqR1K'><span id='rqR1K'><b id='rqR1K'><form id='rqR1K'><ins id='rqR1K'></ins><ul id='rqR1K'></ul><sub id='rqR1K'></sub></form><legend id='rqR1K'></legend><bdo id='rqR1K'><pre id='rqR1K'><center id='rqR1K'></center></pre></bdo></b><th id='rqR1K'></th></span></q></dt></tr></i><div id='rqR1K'><tfoot id='rqR1K'></tfoot><dl id='rqR1K'><fieldset id='rqR1K'></fieldset></dl></div>

          <small id='rqR1K'></small><noframes id='rqR1K'>

              <tbody id='rqR1K'></tbody>

            <tfoot id='rqR1K'></tfoot>

                  本文介绍了如何在 Chrome 扩展中删除事件监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在发出请求后删除 chrome.extension.onRequest.addListener 添加的 onRequest 侦听器,如下所示:

                  I am trying to remove the onRequest listener added by chrome.extension.onRequest.addListener after a request is made, like this:

                  chrome.extension.onRequest.addListener(
                      function(request){
                          chrome.extension.onRequest.removeListener();
                          other_function(request);
                      }
                  );
                  

                  问题是我不知道这是否有效.我尝试了 chrome.extension.onRequest.hasListener,这似乎没有给出正确的答案,所以我想知道是否还有其他方法可以删除 onRequest 侦听器或检查监听器是否存在.

                  The problem is that I don't know if this works or not. I tried chrome.extension.onRequest.hasListener, which seems not to give the right answer, so I am wondering if there are some other ways to remove the onRequest listener or check if the listener exists or not.

                  谢谢!

                  推荐答案

                  removeListener 接受一个参数.您需要命名监听函数,然后按名称将其删除:

                  removeListener takes an argument. You need to name the listener function and then remove it by name:

                  function doStuff(request){
                      chrome.extension.onRequest.removeListener(doStuff);
                      other_function(request);
                  }
                  chrome.extension.onRequest.addListener(doStuff);
                  

                  或者,更简洁:

                  chrome.extension.onRequest.addListener(
                      function doStuff(request){
                          chrome.extension.onRequest.removeListener(doStuff);
                          other_function(request);
                      }
                  );
                  

                  这篇关于如何在 Chrome 扩展中删除事件监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:检测是否支持事件监听器 下一篇:Vuejs - 冒泡自定义事件

                  相关文章

                  最新文章

                  <small id='azK9f'></small><noframes id='azK9f'>

                • <legend id='azK9f'><style id='azK9f'><dir id='azK9f'><q id='azK9f'></q></dir></style></legend>

                    <bdo id='azK9f'></bdo><ul id='azK9f'></ul>
                    <tfoot id='azK9f'></tfoot>
                  1. <i id='azK9f'><tr id='azK9f'><dt id='azK9f'><q id='azK9f'><span id='azK9f'><b id='azK9f'><form id='azK9f'><ins id='azK9f'></ins><ul id='azK9f'></ul><sub id='azK9f'></sub></form><legend id='azK9f'></legend><bdo id='azK9f'><pre id='azK9f'><center id='azK9f'></center></pre></bdo></b><th id='azK9f'></th></span></q></dt></tr></i><div id='azK9f'><tfoot id='azK9f'></tfoot><dl id='azK9f'><fieldset id='azK9f'></fieldset></dl></div>