Vue computed 声明类型时踩坑记录

computed 类型声明需要用泛型

错误写法

const a: Xx[] = computed(()=>{})

正确写法

const a = computed<Xx[]>(()=>{})

直接使用时需要加上 .value

例如

a.value

HTML 中可直接使用

:xx="a"