When a ref on the slot the value is 'undefind'
Vue version
3.2.47
Link to minimal reproduction
Steps to reproduce
Open link
Click Button
What is expected?
ref returns a valid value
What is actually happening?
ref is undefind
System Info
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Memory: 4.16 GB / 15.83 GB
Binaries:
Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - E:\project\dam-intelligent-front\node_modules\.bin\yarn.CMD
npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.63)
Internet Explorer: 11.0.19041.1566
npmPackages:
vue: ~3.2.25 => 3.2.47
Any additional comments?
No response
As far as I know, the ref
attribute only seems to be supported on normal dom
elements as well as on components🤔
@lyric-zemin You can use cloneVNode and withDirectives to realize your functions. I also think it can support the use of ref on slot, which is very useful in component encapsulation。
https://vuejs.org/api/built-in-special-elements.html#slot
As the document says, attributes other than name
will be passed as props of scoped slots when applied to slots, so it is urgent to bind ref
in the parent component
Solution