【发布时间】:2021-07-23 13:44:16
【问题描述】:
我有一个名为 sortSearch 的道具,它是来自父调用者的函数或回调。
type SortSearchInterface = (
currentSort: string,
currentSortDir: string
) => void;
export default defineComponent({
props: {
//sortSearch: {
//type: Function as PropType<(currentSort: string, currentSortDir: string)=> void>
// type: Function as PropType<SortSearchInterface>|undefined
// }
sortSearch: Function as PropType<SortSearchInterface>,
},
当attempting to call this function 出现以下错误Cannot invoke an object which is possibly 'undefined':
// Cannot invoke an object which is possibly 'undefined'.Vetur(2722)
//props.sortSearch(s, state.currentSortDir);
通过我的简短谷歌搜索,发现这方面的示例/文档非常有限,感谢任何帮助。
【问题讨论】:
标签: typescript vuejs3 vue-composition-api