Vue Computed
HTML
<script src="https://unpkg.com/[email protected]"></script>
<div id="app">
<p v-text="fullName"></p>
</div>
JavaScript
var app = new Vue({
el: '#app',
data: {
firstName: "Ardani",
lastName: "Rohman"
},
mounted:function() {
this.changeFirstName();
},
methods: {
changeFirstName: function () {
return this.firstName = "Rohman";
}
},
computed: {
fullName: function () {
return [this.firstName,this.lastName].join(' ');
}
}
})