Subscribe on changes!

props of vnode didn't initialize

avatar
Jun 27th 2021

Version

3.1.2

Reproduction link

https://codesandbox.io/s/boring-hofstadter-h2jee

Steps to reproduce

Hi, please look at the console. image

What is expected?

It's expected to get merged props, like

{
  "aBC": "a-b-c",
  "a1": "a1",
  "b2": "b2",
  "c3": "c3",
}

What is actually happening?

The props of vnode didn't convert to camel case, and there's no default props, such as a1 b2 c3.

avatar
Jun 27th 2021

duplicate of #3953

@edison1105 Sorry, I didn't want to mention undefined attrs are not being passed, so I changed the description. I give all type.props a default value. How can the props convert to camel case automatically? Like a-b-c to aBC. And is there any way to merge type.props to props?

avatar
Jun 27th 2021

is this what you want: https://codesandbox.io/s/frosty-flower-21wge?file=/src/components/HelloWorld.vue I'm a bit confused about your feature.

avatar
Jun 27th 2021

is this what you want: https://codesandbox.io/s/frosty-flower-21wge?file=/src/components/HelloWorld.vue I'm a bit confused about your feature.

Yes, I mean this. It's the same value of props in setup. But I wonder why they are different.

This is the link that I got props in setup. https://codesandbox.io/s/competent-chatterjee-y5ipx?file=/src/components/HelloWorld.vue

avatar
Jun 27th 2021

vnode.props only contains the props actually passed to the vnode during render of the parent. default values and camelCase conversion are handled in the component instance and are not reflected on the vnode.

This is not a bug. Think of vnode.props as the raw input.