有没有办法跟踪自定义事件,特别是像主干中的那些非 DOM 事件?
thisObj.on("custom:triggeredEvents", function() { do.stuffHere() });
thisObj.trigger("custom:triggeredEvents");
干杯!
最佳答案
您应该看看 observer pattern .
如果你不想自己实现这个,你可以使用现有的库,例如https://github.com/mroderick/PubSubJS
关于Javascript:跟踪自定义事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17270781/