Vue.js convert string to uppercase


We can use native JavaScript function to convert string to uppercase. JavaScript function toUpperCase() is used to convert a string to Uppercase. Here in this tutorial, we are going to explain how you can use this function is vuejs. You can use our online editor to edit and run the code online.


Vue.js convert string to uppercase Example

You can convert string to uppercase simply as below-

Example:

<div id="app">	
	<p>{{myStr}}</p>
	<p>{{myStr2}}</p>
	<button @click="myFunction()">Click Me</button>
</div>
<script>
 new Vue({
el: '#app',
  
  data: { 
	  myStr:"Hello World!",
	  myStr2:""
  },
  
   methods:{
    myFunction: function () {	
		this.myStr2 = this.myStr.toUpperCase();
    }
   }

});
</script> 

Try it »

Output of above example-

Vue.js convert string to uppercase

Advertisements

Add Comment

📖 Read More