kaleidosJohna
kaleidosJohna
  • 发布:2025-01-15 18:18
  • 更新:2025-01-15 19:00
  • 阅读:49

【uts】type类型属性hide是可选的函数,调用时提示报错

分类:uts

类型是这样的

export type IMenuItem = {  
  title : string,  
  data : IMenuSubItem[],  
  iconSize ?: string,  
  badge ?: number[],  
  click ?: (item : IMenuSubItem, index : number) => void,  
  hide ?: () => boolean,  
} 

调用后报错

18:15:09.815 ‌error: Reference has a nullable type '(() -> Boolean)?', use explicit '?.invoke()' to make a function-like call instead‌  
18:15:09.815 at pages/tabbar/my.uvue:223:31  
18:15:09.815 221|   const menuList = computed(() => {  
18:15:09.815 222|    return MENU_LIST.filter((v) => {  
18:15:09.815 223|     return v?.hide == null || v.hide() == false;  
18:15:09.816    |                                 ^  
18:15:09.816 224|    });  
18:15:09.816 225|   }); 
2025-01-15 18:18 负责人:无 分享
已邀请:
kaleidosJohna

kaleidosJohna (作者)

已解决

要回复问题请先登录注册