vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.75k stars 8.35k forks source link

组件无法正确解析 v-bind="toRefs(props)" #12325

Open guaijie opened 2 weeks ago

guaijie commented 2 weeks ago

Vue version

3.5.3

Link to minimal reproduction

https://play.vuejs.org/#eNp9Uk1v1DAQ/SuWL7tIS6JuOEVpEaAe4ABV4ehLNpkEF8e2bCcsivLfGU8+uq3aXhL7vfl4M34j/2RtMvTAc174ykkbmIfQ2xuhZWeNC2xkwdxD4w/MQVkFOQCbWONMx3aYt9vivpjOLniSxkssi3RltA/MOmM9u95q7MeIXOXs6kDcMWfB9TBfspztjrvp3ZrssD3mzjr2VGrjRspYqyz5qDC2arzQQhfpPBiOhJcAnVVlALwxVpDo4f1J6vpacMrgLL3gcqqOHP2RJOC4AMcVyBYgW9KL9KIPP/DgUW0j2+TBG427HmMHwStsIRW4HzZInEbwnBETuVIp8/cbYbSZFa9+Q/XnBfzBnyMm+J0DD24AwTculK6FMNO3P7/DGc8b2Zm6Vxj9BnkP3qg+apzDPve6RtkXcaT2KzlB6vaXvz0H0H4dKgqNkRPFC47OiNt9bfRHuVnygfKEnnCLq6uem5WpUrf4AgHL4L7DPwvsbjEcFaXH+5gz3XcncCSCng+hkzEKSnTGDGUI+eBwBmz53Lw1NFIDVS7oe7NHH85RWCVRpt3c+ZbrajnQAY9embAaLp3xp96Z/gMicTkE

Steps to reproduce

image

What is expected?

我并不清楚这是否是一个 bug,还是说这么处理是官方有意为之。如果是官方默认行为,我创建了一个讨论,并希望官方能进行支持。这一行为是符合直觉的。

props 传递过程中支持解构 refs

What is actually happening?

no response

System Info

No response

Any additional comments?

No response

YiMo1 commented 2 weeks ago

并不是bug,在文档中有说明到,只有顶层的ref才会在模板中自动解包。参考

在你的示例代码中,你可以将v-bind="refs"改为v-bind="props"