how to set template refs in render function #7257
Unanswered
coader
asked this question in
Help/Questions
Replies: 3 comments
-
after search in code, I found that it alwasy pass null as parentComopnent to render
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I think you can use this: <script setup>
import { ref,onMounted ,h,render} from 'vue'
const div = ref(null)
const a = ref(null)
const b=ref(false)
onMounted(() => {
const test = h('div', { ref: a }, 'test')
render(test, div.value)
console.log(test.el) // this may be same as ref
b.value = a.value == null
})
const msg = ref('Hello World')
</script>
<template>
<h1>{{ msg }}</h1>
<input v-model="msg">
<div ref="div" ></div>{{b}}
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
-
yes, it's the same as setRef |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
https://sfc.vuejs.org/#eNp9kbFuhDAMhl/FygIncaCuCJC6dencJQsc5uAUkigJdEB599pwd6raqkJC9u/ks/N7E6/W5uuCohSVv7jJBvAYFttIPc3WuAAbOBwyo9/NogP2kI2ZQ92jizA4M0NCtxOpAaS+GO0D9NMKNV9K9aLU6SG3f4ldzdLQKo+kPZuk6Qnqhloz9zgZkH41jGlC/CQ7xiqJGjNIuJgQAEjk0VIWMp4kX1u1MJuL3ZERpn1ENfA8UsfnSLO/3idN3lApAx/GqZ7p/FXF4RL5Q0nA2ao2IGUA1fjSbNt+P8aqoGxXJ22XAOt5Nj2qWgqqS3GU2ClqRCJFUkBTFRQQpIuRWz3xIhPHNs5za/ObN5r2te2m3wteihJ2hTVaCedSjCFYXxaFHy685ZvPjbsWFOWOjJ5mzNHP586ZT4+OwFJk3xgFiSu682Equv+YP47+4jKWHhVF/AIRVNb3
it's still nothing after render
Beta Was this translation helpful? Give feedback.
All reactions