I utilized nexttick alongside an async method to update a DOM element.
However, I am encountering issues with returning the correct style type.
An error message pops up stating:
error TS2322: Type 'Promise<{ maxHeight: string; }>' is not assignable to type 'StyleValue | undefined'. Type 'Promise<{ maxHeight: string; }>' is missing the following properties from type 'StyleValue[]': length, pop, push, concat, and 28 more.
<template>
<div :style="getHeight(i)" class="demo" v-for="i in [1,2]">Hi</div>
</template>
<script lang="ts">
import {defineComponent, reactive, nextTick} from 'vue'
export default {
setup() {
const getHeight = async (i: number) => {
await nextTick()
return {maxHeight: '12px'}
};
return {getHeight}
}
}
</script>
<style>
.demo {
border: 1px solid red;
}
</style>