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

浙公网安备 33010602011771号