class Phone{
name = '手机'
change(){
console.log('123')
}
}
const p = new Phone()
console.log(p.name)
在不加static之前,p能获取刀Phone的属性,
class Phone{
static name = '手机'
change(){
console.log('123')
}
}
const p = new Phone()
console.log(p.name)
添加static过后:
static就是声明静态属性的前缀