Vue.js computed속성의 setter함수
Vue.js computed속성의 setter함수
computed속성은 기본적으로 getter함수만 가지고 있지만,
필요한 경우 setter함수를 만들어 쓸 수 있습니다.
JS부분
//...
computed:{
fullName:{
//getter
get: function(){
return this.firstName + ' ' + this.lastName
},
//setter
set: function(newValue){
var names = newValue.split(' ')
this.firstName = names[0]
this.lastName = names[names.length-1]
}
}
}
//....
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기