Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript &引用;期望目标,得到承诺。”;承诺作为道具传递时出错_Javascript_Typescript_Vue.js_Vuejs2 - Fatal编程技术网

Javascript &引用;期望目标,得到承诺。”;承诺作为道具传递时出错

Javascript &引用;期望目标,得到承诺。”;承诺作为道具传递时出错,javascript,typescript,vue.js,vuejs2,Javascript,Typescript,Vue.js,Vuejs2,我只是尝试将一个承诺作为道具传递给期望承诺的子组件,但我有一个错误,它告诉我期望的类型是Object 我使用,并为我的项目 我的代码如下所示: 从“Vue属性装饰器”导入{Component,Vue,Prop,Inject} 从“@/api/model/referentiel”导入{EditableReferentielModel} 从“@/api/resources/referentiel”导入引用资源 从“@/api/resources/index”导入{axiossresponseext

我只是尝试将一个承诺作为道具传递给期望承诺的子组件,但我有一个错误,它告诉我期望的类型是Object

我使用,并为我的项目

我的代码如下所示:


从“Vue属性装饰器”导入{Component,Vue,Prop,Inject}
从“@/api/model/referentiel”导入{EditableReferentielModel}
从“@/api/resources/referentiel”导入引用资源
从“@/api/resources/index”导入{axiossresponseext}
导出默认类ParentComponent扩展Vue{
@注入()
参考资源:参考资源
listAsPromise:Promise=this.referentielResource.getStatedeDevelopment()
}

从“Vue属性装饰器”导入{Component,Vue,Prop,Inject}
从“@/api/resources/referentiel”导入引用资源
从“@/api/model/referentiel”导入{EditableReferentielModel}
从“@/api/resources/index”导入{axiossresponseext}
@组成部分
导出默认类ChildComponent扩展Vue{
@注入()
参考资源:参考资源
@Prop({default:null})
值:EditableReferenceModel | null
@Prop({default:null})
承诺:承诺
referentiel:EditableReferentielModel[]=[]
选中:EditableReferentielModel | null=this.value
异步装入(){
this.referentiel=等待this.listPromise
}
}
使用此代码,我仍然有以下错误:
[Vue warn]:无效的属性:属性“listPromise”的类型检查失败。预期对象,已获得承诺。
即使
listPromise
类型设置为
any


怎么了?

您是否将其默认值设置为
null
?(我不知道typescript…)如果是,请尝试删除它。由于
null
被视为对象,我会将默认值设置为
null
。但是,即使我删除了默认值,或者将预期类型设置为
Promise | null