Vue.Js String Concat


Vue.Js String Concat– You can use native JavaScript concat method to join two or more strings. Here in this tutorial, we are going to explain how you can concat two strings in vuejs.


Concat two String in Vue.JS

You can concat two strings simply as below-

Example:

<!DOCTYPE html>
<html>
<head>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script>
</head>
<body>
<div id="app">
<input v-model="firstName" @change='concatFunction' placeholder="Enter First Name"><br>
<input v-model="lastName" @change='concatFunction' placeholder="Enter Last Name"><br>
	{{fullName}}
</div>
<script>
 new Vue({

el: '#app',
  
  data: { 
	  firstName:"",
	  lastName:"",
	  fullName:""
  },
  
   methods:{
    concatFunction: function () {
      var v = this;
	  v.fullName = v.firstName.concat(v.lastName);
   }
	}
 

});
</script>        
</body>
</html>

Try it »

Output of above example-

Vue.Js String Concat Example

Advertisements

Add Comment

📖 Read More