You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/extras/render-function.md
+13-10
Original file line number
Diff line number
Diff line change
@@ -706,36 +706,39 @@ If the directive is registered by name and cannot be imported directly, it can b
706
706
707
707
<divclass="composition-api">
708
708
709
-
With the Composition API, template refs are created by passing the `ref()` itself as a prop to the vnode:
709
+
With the Composition API, when using [`useTemplateRef()`](/api/composition-api-helpers#usetemplateref) <supclass="vt-badge"data-text="3.5+" /> template refs are created by passing the string value as prop to the vnode:
710
710
711
711
```js
712
-
import { h, ref } from'vue'
712
+
import { h, useTemplateRef } from'vue'
713
713
714
714
exportdefault {
715
715
setup() {
716
-
constdivEl=ref()
716
+
constdivEl=useTemplateRef('my-div')
717
717
718
-
// <div ref="divEl">
719
-
return () =>h('div', { ref:divEl })
718
+
// <div ref="my-div">
719
+
return () =>h('div', { ref:'my-div' })
720
720
}
721
721
}
722
722
```
723
723
724
-
or (with version >= 3.5)
724
+
<details>
725
+
<summary>Usage before 3.5</summary>
726
+
727
+
In versions before 3.5 where useTemplateRef() was not introduced, template refs are created by passing the ref() itself as a prop to the vnode:
0 commit comments