Skip to content

Commit

Permalink
fix:(修复业务代码报错会导致钩子执行多次问题)
Browse files Browse the repository at this point in the history
  • Loading branch information
qi committed Apr 11, 2022
1 parent 861a7b9 commit 892e563
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/spa-custom-hooks/custom-hook.js
Expand Up @@ -96,8 +96,8 @@ export default class customHook {
let customHook = this.customHooks[name];
let meet = customHook.inscape.every(e => this.hook[e].need && this.checkHookHit(this.hook[e]))
if (meet && !customHook.execute) {
this.customHooks[name]['callback'](this.options);
customHook.execute = true;
this.customHooks[name]['callback'](this.options);
}
});
}
Expand All @@ -120,6 +120,7 @@ export default class customHook {
* return hookArr {Array string} 钩子构成数组
*/
splitHook(name){
//分割算法待优化、目前只支持单名大写开头的钩子、比如beforeCreate暂不支持
name = name.replace('on', '').split(/(?=[A-Z])/);
const hooksAll = [...new Set(nativeHooksName.concat(getDiyHooks()))].sort((a,b)=>b.length - a.length);
const hookArr = [];
Expand Down

0 comments on commit 892e563

Please sign in to comment.