组件支持直接传递 ref 类型数据 #724
guaijie
started this conversation in
RFC Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在模板语法中,组件并不能直接传递 Ref 类型数据,需要通过编译器对 Ref 类型数据进行解包。事实上,我们可以在组件中通过判断其是否具有某一私有变量(例如 symbol)来区分 Ref 与 { value: any } 类型。
这样可以使得组件间数据交互变得更加简单,且向下兼容,不会出现破坏性的更改
同样的,在 tsx 中
Beta Was this translation helpful? Give feedback.
All reactions