Skip to content

Commit

Permalink
fix: Cannot read properties of undefined (reading 'createBtn') #303 (#…
Browse files Browse the repository at this point in the history
…304)

* fix: Cannot read properties of undefined (reading 'createBtn') #303
  • Loading branch information
ThinkHalo authored and lyngai committed Aug 16, 2022
1 parent f8bae8b commit 1fc3689
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/toolbars/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ export default class Toolbar {
if (level2MenusName) {
level2MenusName.forEach((level2Name) => {
const subMenu = this.menus.hooks[level2Name];
const btn = subMenu.createBtn(true);
// 二级菜单的dom认定为一级菜单的
subMenu.dom = subMenu.dom ? subMenu.dom : this.menus.hooks[name].dom;
btn.addEventListener('click', (event) => this.onClick(event, level2Name, true), false);
this.subMenus[name].appendChild(btn);
if (subMenu !== undefined && typeof subMenu.createBtn === 'function') {
const btn = subMenu.createBtn(true);
// 二级菜单的dom认定为一级菜单的
subMenu.dom = subMenu.dom ? subMenu.dom : this.menus.hooks[name].dom;
btn.addEventListener('click', (event) => this.onClick(event, level2Name, true), false);
this.subMenus[name].appendChild(btn);
}
});
}
// 兼容旧版本配置的二级菜单
Expand Down

0 comments on commit 1fc3689

Please sign in to comment.