Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-for 多个类型推导为 item: unknown #4812

Open
wxwebfeng opened this issue Sep 4, 2024 · 3 comments
Open

v-for 多个类型推导为 item: unknown #4812

wxwebfeng opened this issue Sep 4, 2024 · 3 comments

Comments

@Shyam-Chen
Copy link

Shyam-Chen commented Sep 4, 2024

const infos = ref<Info[]>([]);

You need to convert infokey and Info into an Info[] array based on your own judgment criteria.


Or render separately:

<template v-if="Array.isArray(data)">
  <div v-for="item in data" :key="item.id">{{ item.id }}</div>
</template>

<template v-else>
  <div v-for="(val, key) in data" :key="val.id">{{ val.id }}</div>
</template>

@baiwusanyu-c
Copy link
Member

const data = ref<InfoList | InfoObj[]>([])

@yyx990803
Copy link
Member

This should be in the scope of language tools and how v-for codegen works. Transferring over.

@yyx990803 yyx990803 transferred this issue from vuejs/core Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants