-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Open
Labels
package: vue@ionic/vue package@ionic/vue packagetype: buga confirmed bug reporta confirmed bug report
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
create a reference in dom, which is inside Icon-vue component, then get the config "offsetHeight", "offsetWidth", "clientHeight", "clientWidth" of the dom in lifecycle onMouted, but their value are all zero, and when I add setTimeout function to get config, it will get real value.
Expected Behavior
it can get the real value of config "offsetHeight", "offsetWidth", "clientHeight", "clientWidth" of the dom reference in lifecycle onMouted.
Steps to Reproduce
- set dom reference inside ionic-vue component
- in lifecycle onMouted, get the config "offsetHeight", "offsetWidth", "clientHeight", "clientWidth" value
here is the code:
<template>
<ion-page>
<div ref="domRef">dom test</div>
</ion-page>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue';
import { IonPage } from '@ionic/vue';
export default defineComponent({
name: 'App',
components: {
IonPage
},
setup() {
const domRef = ref<HTMLElement | null>(null)
onMounted(() => {
console.log(domRef.value) // it can get dom reference
console.log(domRef.value?.offsetHeight) // but the value is zero
console.log(domRef.value?.offsetWidth)
console.log(domRef.value?.clientHeight)
console.log(domRef.value?.clientWidth)
})
return {
domRef
}
}
});
</script>
<style scoped></style>
Code Reproduction URL
No response
Ionic Info
No response
Additional Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
package: vue@ionic/vue package@ionic/vue packagetype: buga confirmed bug reporta confirmed bug report