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 · 5 comments
Open

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

wxwebfeng opened this issue Sep 4, 2024 · 5 comments
Labels
bug Something isn't working 🔩 p2-edge-case

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
@robokozo
Copy link

robokozo commented Oct 29, 2024

I'm seeing similar things.
image
image

I'm in a VS Code Remote session
image

I've started seeing this error yesterday. Could it be related?
image

Rolling back Vue Official to 2.1.6 fixed it for me

@robokozo
Copy link

@wxwebfeng upgrading to v2.1.10 fixed my issue. is yours resolved?

@KazariEX KazariEX added bug Something isn't working 🔩 p2-edge-case labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🔩 p2-edge-case
Projects
None yet
Development

No branches or pull requests

6 participants