Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError when using SubMenu in h function #3973

Open
1 task done
Ljzn opened this issue Apr 21, 2021 · 1 comment
Open
1 task done

Uncaught TypeError when using SubMenu in h function #3973

Ljzn opened this issue Apr 21, 2021 · 1 comment

Comments

@Ljzn
Copy link

Ljzn commented Apr 21, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

undefined

Environment

macOS Big Sur, Chrome 89

Reproduction link

https://github.com/Ljzn/vue3-default-slot-error/blob/main/src/main.js

Steps to reproduce

use default slot in a-menu-item, under a-sub-menu

import { h, createApp, resolveComponent } from 'vue'
import antd from 'ant-design-vue'

const titleSlot = () => h('span', null, 'submenu')

// following causes typeError

const menuItems = () => [
  h(resolveComponent('a-menu-item'), {
    key: 1
  }, { default: () => 'item1' })
]

// following code causes warning, but no error

// const menuItems = () => [
//   h(resolveComponent('a-menu-item'), {
//     key: 1
//   }, 'item1')
// ]

const app = (props, ctx) => h(
  resolveComponent('a-menu'),
  {
    mode: 'inline'
  },
  {
    default: () => [
      h(
        resolveComponent('a-sub-menu'),
        {},
        {
          default: menuItems,
          title: titleSlot
        }
      )
    ]
  }
)

createApp(app)
  .use(antd)
  .mount('#app')

What is expected?

no error

What is actually happening?

Uncaught TypeError: children.forEach is not a function
at loopMenuItemRecursively (util.js:33)
at util.js:48
at Array.forEach (<anonymous>)
at loopMenuItemRecursively (util.js:33)
at Proxy.isChildrenSelected2 (SubMenu.js:200)
at Proxy.render39 (SubMenu.js:494)
at renderComponentRoot (runtime-core.esm-bundler.js:846)
at componentEffect (runtime-core.esm-bundler.js:4280)
at reactiveEffect (reactivity.esm-bundler.js:42)
at effect (reactivity.esm-bundler.js:17)
@Ljzn
Copy link
Author

Ljzn commented Apr 21, 2021

can be temporary fixed by return an array in menu-item

const menuItems = () => [
  h(resolveComponent('a-menu-item'), {
    key: 1
  }, { default: () => ['item1'] })
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants