为元素的事件添加处理函数。处理函数在每个元素上每种事件类型最多执行一次。
eventer.one(elm, event, selector, data, callback)
Example: 处理函数在每个元素上每种事件类型只执行一次。
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <div class="count">0</div> <button class="target">Counter</button> <script> require(["skylark/query", "skylark/eventer"], function($, eventer) { var count = $(".count"), value = count.text(); eventer.one($(".target")[0], "click mouseenter", function() { count.html(++value); }); }); </script> </body> </html>