计算属性完整写法
<script type="text/javascript">
const vm = new Vue({
el:"#root",
data:{
firstName:'张',
lastName:'三胖',
},
computed:{
fullName:{
get(){
return `${this.firstName}-${this.lastName}`
},
set( value){
let arr = value.split('-')
this.firstName = arr[0]
this.lastName = arr[1]
}
}
计算属性简写 - 只读取不修改可用简写
fullName(){
return `${this.firstName}-${this.lastName}`
}