
首先是插件类
class Plugin { constructor(element, options) { this._setup(element, options); var pluginName = getPluginName(this); this.uuid = GetYoDigits(6, pluginName); if(!this.$element.attr(`data-${pluginName}`)){ this.$element.attr(`data-${pluginName}`, this.uuid); } if(!this.$element.data('zfPlugin')){ this.$element.data('zfPlugin', this); } /** * Fires when the plugin has initialized. * @event Plugin#init */ this.$element.trigger(`init.zf.${pluginName}`); } destroy() { this._destroy(); var pluginName = getPluginName(this); this.$element.removeAttr(`data-${pluginName}`).removeData('zfPlugin') /** * Fires when the plugin has been destroyed. * @event Plugin#destroyed */ .trigger(`destroyed.zf.${pluginName}`); for(var prop in this){ this[prop] = null;//clean up script to prep for garbage collection. } } } 这段代码里面的 init.zf.${pluginName} 和 destroyed.zf.${pluginName} 事件都找不到任何声明,在扩展的具体插件里面也没有声明这两个事件,请问这里的 trigger 有什么用?有特殊的作用吗?