interface TabItemType {
author: {
avatar_url: string;
loginname: string;
};
author_id: string;
content: string;
create_at: string;
good: boolean;
id: string;
last_reply_at: string;
reply_count: number;
tab: string;
title: string;
top: boolean;
visit_count: number;
}
const tabItem:TabItemType|null = ref(null)
此时提示错误:类型“Ref<null, null>”缺少类型“TabItemType”的以下属性: author, author_id, content, create_at 及其他 8 项。ts-plugin(2740)
因为 tabItem 被初始化为 null,与 TabItemType 接口不匹配,可以用一个符合 TabItemType 结构的对象来初始化 tabItem