4. computed
HTML
<div id="app">
<div v-text="usernameResolver">
</div>
<button @click="change">click
</button>
</div>
Vue
new Vue({
el: '#app',
data: {
count: 0,
username: '',
newValue: '',
},
methods: {
change: function() {
this.username;
},
math: function() {
return Math.random();
}
},
computed: {
getCount() {
return this.count + '개';
},
usernameResolver: {
get() {
return this.username + this.math();
},
set(newValue) {
this.username = newValue;
this.newValue = newValue + '♡';
},
}
}
});