VUE 3打字稿道具:[Vue Warn]:无效的道具:类型检查失败了“组织”。预期null |布尔,有对象
我正在使用类Quasar/Vue构建应用程序。我将“组织”对象传递到
<q-tab-panel name="roles">
<OrganisationRolesTab :organisation="organisation"></OrganisationRolesTab>
</q-tab-panel>
OrganisationRolestab中的组件。即使我通过DefineProps通用符号定义了“组织”,Iormanisation:
<template>
{{ organisation }}
</template>
<script setup lang="ts">
import { IOrganisation } from 'src/interfaces/IOrganisation'
defineProps<{ organisation: IOrganisation | false }>()
</script>
Iorganization是:
export interface IOrganisation {
id?: string
title: string
shortTitle: string
createdAt?: Date
updatedAt?: Date
}
这给了我的警告:
runtime-core.esm-bundler.js?f781:38 [Vue warn]: Invalid prop: type check failed for prop "organisation". Expected Null | Boolean, got Object
at <OrganisationRolesTab organisation= {id: '94de89d3-38f2-4410-bf86-74db781b18aa', createdAt: '2022-06-13T15:11:45.185Z', updatedAt: '2022-07-03T14:24:26.103Z', title: 'Test organisation', shortTitle: 'test'} >
at <QTabPanel name="roles" >
at <BaseTransition appear=false persisted=false mode=undefined ... >
at <Transition name="q-transition--slide-right" >
at <QTabPanels modelValue="roles" onUpdate:modelValue=fn animated="" >
at <OrganisationEdit onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy {__v_skip: true} > >
at <RouterView>
at <QPageContainer class="q-ma-sm" >
at <QLayout view="lHh Lpr lFf" >
at <MainLayout onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy {$i18n: {…}, $t: ƒ, $rt: ƒ, …} > >
at <RouterView>
at <App>
我如何摆脱此警告而不会丢失。打字?
I'm building an app with Quasar/Vue. I'm passing the "organisation" object to the component
<q-tab-panel name="roles">
<OrganisationRolesTab :organisation="organisation"></OrganisationRolesTab>
</q-tab-panel>
Inside OrganisationRolesTab.vue I define the prop "organisation" via the defineProps generic notation:
<template>
{{ organisation }}
</template>
<script setup lang="ts">
import { IOrganisation } from 'src/interfaces/IOrganisation'
defineProps<{ organisation: IOrganisation | false }>()
</script>
IOrganisation is:
export interface IOrganisation {
id?: string
title: string
shortTitle: string
createdAt?: Date
updatedAt?: Date
}
This gives me the warning in console:
runtime-core.esm-bundler.js?f781:38 [Vue warn]: Invalid prop: type check failed for prop "organisation". Expected Null | Boolean, got Object
at <OrganisationRolesTab organisation= {id: '94de89d3-38f2-4410-bf86-74db781b18aa', createdAt: '2022-06-13T15:11:45.185Z', updatedAt: '2022-07-03T14:24:26.103Z', title: 'Test organisation', shortTitle: 'test'} >
at <QTabPanel name="roles" >
at <BaseTransition appear=false persisted=false mode=undefined ... >
at <Transition name="q-transition--slide-right" >
at <QTabPanels modelValue="roles" onUpdate:modelValue=fn animated="" >
at <OrganisationEdit onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy {__v_skip: true} > >
at <RouterView>
at <QPageContainer class="q-ma-sm" >
at <QLayout view="lHh Lpr lFf" >
at <MainLayout onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy {$i18n: {…}, $t: ƒ, $rt: ƒ, …} > >
at <RouterView>
at <App>
How do I get rid of this warning without losing the typing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
docs 说明
defineprops的限制/代码>:
解决方法是使用
defineprops
的等效选项参数:The docs state the limitations of
defineProps
:A workaround is to use the equivalent options argument of
defineProps
: