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
Use Setup sugar in the children component.and set the ref equals dom to the root element.
Const a ref variable named dom.
Use ref function in the parent component, and then you cannot get the ref obejct in the ref function's first param.
What is expected?
using Setup sugar in the children component and set the ref attr to the root element won't cause ref function's first param missing in the parent component.
What is actually happening?
Sugar.vue is the children component of the App.vue. When I use ref sugar in the Sugar.vue, I cannot get the ref object in the setRef's first param. It's an empty object. But with no sugar in the NoSugar.vue, I can get the ref object correctly in the setRef's first param. App.vue
<template>
<sugar :ref="setRef" />
<no-sugar :ref="setRef" />
</template>
<script lang="ts">
export default {
setup() {
const setRef = el => {
// el is an empty object
};
const setRefNoSugar = el => {
// el is correct
};
return { setRef, setRefNoSugar };
}
};
</script>
it works
<script lang="ts">
import { ref, onMounted } from 'vue';
export default {
setup() {
const dom = ref();
return { dom };
},
};
</script>
it does not work
<script lang="ts" setup>
import { ref } from 'vue';
const dom = ref();
</script>
Version
3.0.11
Reproduction link
link
Steps to reproduce
ref
equalsdom
to the root element.dom
.What is expected?
using Setup sugar in the children component and set the ref attr to the root element won't cause ref function's first param missing in the parent component.
What is actually happening?
Sugar.vue is the children component of the App.vue. When I use ref sugar in the Sugar.vue, I cannot get the ref object in the setRef's first param. It's an empty object. But with no sugar in the NoSugar.vue, I can get the ref object correctly in the setRef's first param.
App.vue
it works
it does not work
Here is my repo.
The text was updated successfully, but these errors were encountered: