let obj = {
_name: null,
get name() {
return this._name
},
set name(name) {
if (typeof name !== 'string') {
return console.log('赋值类型必须为 String')
} else {
this._name = name
}
}
}