Subscribe on changes!

When a ref on the slot the value is 'undefind'

avatar
Mar 6th 2023

Vue version

3.2.47

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9UstuwjAQ/JWVL4AE9h0Z1Io/6NkXCBsaGj9kO6mqKP/e3Ti0lFbNaXdnPB7PZhDPIci+Q7EVOlWxCRkS5i7sjWts8DHDwdsAdfQWFlJxw/SFcVoVPjGpyWhDe8xIHYBm2lSZrM9NP5X82Q9oEqTW5zLR6obqSZpKre6kxFoUFxt7DPKavCOfwyQ8A8mILUwTnpEz7o14zTmkrVKprtjuNUkfL4oqGTuXG4sSk92con9PGEnYiPWdhqJhj3ET0Z0xYvxP84H6S5dlR+NGesotPM76Z16cCESsd0Zw+YK1EaBKgoyfupy9g6eqbao3Inl34MqIOVlWLikW5mOO1P693IEuHeftlrUaV3mXiFh8wI59LVffwHw3AcsV7PYlfIZ8i7L1l+V8UvbHtkM6SK//+lfE+AlhXtaW

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

avatar
Mar 6th 2023

As far as I know, the ref attribute only seems to be supported on normal dom elements as well as on components🤔

avatar
Mar 6th 2023

@baiwusanyu-c But support template and component

avatar
Mar 6th 2023

@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。

avatar
Mar 6th 2023

image 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