vue3的reactive变量声明类型注解

1 使用默认类型

const person = reactive({
  name: 'zs',
  age: 20
})
console.log(person.name);

2 使用泛型

type GoodType = {
  name: string
  id: number
  price: number
  pic?: string
}
let info = reactive<GoodType>({
  name: 'zs',
  id: 20,
  price: 200,
  pic: 'xxx'
})
info.price

  

posted @ 2024-06-19 20:24  light丶  阅读(115)  评论(0)    收藏  举报