Vue.js decode URL


We can use decodeURIComponent function to decode URL. Here in this tutorial, we are going to explian how you can use this method to decode URL in vue.js. You can also use our online editor to edit and run the code online.


Vue.js decode URL Example

You can use decodeURIComponent to decode the url in vue.js.

Example:

<div id="app">
	<p>Result 1 = {{result}}</p>
	<button @click="myFunction()">Click Me</button>
</div>
<script>
 new Vue({
 el: '#app',
  
  data: {
	  result:'',
	  myUrl: 'http%3A%2F%2Fwww.example.com%2Findex.html%3Fparam%3D1%26param%3D2'
  },  
   methods:{
    myFunction: function () {
	 this.result = decodeURIComponent(this.myUrl);
    }
   }
});
</script>  

Try it »

Output of above example-

Vue.js decode url

Advertisements

Add Comment

📖 Read More