How to concatenate string with two adding variable use Vuejs. i have used below code but string i am not able to concatenate to variables. please check and solve my issue.
<div id = "vue_det">
<h1>Firstname : {{firstname}}</h1>
<h1>Lastname : {{lastname}}</h1>
<h1>{{test()}}</h1>
</div>
<script type = "text/javascript" src = "js/vue_instance.js"></script>
<script>
var vm = new Vue({
el: '#vue_det',
data: {
firstname : 10,
lastname : 20,
},
methods: {
test : function() {
return "result"+ this.firstname+this.lastname;
}
}
})
</script>
</body>
return "result" + (this.firstname + this.lastname);, with parentheses to ensure the numbers are added as numbers. I suggest giving them better names thanfirstnameandlastnameas those property names do imply that you'd want string concatenation and not number addition.