hg-sid
Version:
a front-end simple framework with mvc
24 lines (21 loc) • 501 B
text/typescript
import DD from '.'
export const LIFECYCLE_HOOK = [
'beforeCreate',
'created',
'beforeDestroy',
'destroyed'
]
/**
* 触发实例下的对应生命周期,同时触发对应事件,用于用户自定义制定对应处理事件
* @param dd
* @param hook
*/
export function callHook (dd: DD, hook: string): void {
const handler = dd.$options[hook]
if (handler) {
for (let i = 0, j = handler.length; i < j; i++) {
handler[i].call(dd)
}
}
// dd.$emit('hook:' + hook)
}