ionic-team / ionic-team/ionic-framework

bug: vue, elements not shown at the moment did enter lifecycle is fired

Abierto
#24,434 23 comentarios 0 reacciones 0 asignados Ver en GitHub
package: vue type: bug
Lenguaje dominante
TypeScript
Estrellas
52.7k
Forks
13.3k
Merge medio
1 d 15 h
PR fusionados (30 d)
51

Descripción

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

- [ ] v4.x
- [X] v5.x
- [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

1. set dom reference inside ionic-vue component
2. in lifecycle onMouted, get the config "offsetHeight", "offsetWidth", "clientHeight", "clientWidth" value

here is the code:

```


dom test

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
}
}
});

```

### Code Reproduction URL

_No response_

### Ionic Info

_No response_

### Additional Information

_No response_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.