Skip to content
New issue

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

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

Already on GitHub? # to your account

不能将类型“{}”分配给类型“(props: Readonly<Props>) => KV<unknown>”。 类型“{}”提供的内容与签名“(props: Readonly<Props>): KV<unknown>”不匹配。ts(2322) #7

Open
any86 opened this issue Mar 1, 2022 · 0 comments

Comments

@any86
Copy link
Owner

any86 commented Mar 1, 2022

interface Props {
  modelValue: KV;
  items?: Item[];
}

const props = withDefaults(defineProps<Props>(),{
 // 🔥 问题就出在这里 ↓
  modelValue:{},
});

不要忘记了引用型数据作为默认值, 要嵌套一层函数, 修改为:

const props = withDefaults(defineProps<Props>(),{
  modelValue:()=>({}),
});
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant