How to get current URL in Vue JS?

Are you wanted to get current url in your Vue js app ? If yes then you are a right place. if you are working with plan vuejs without using vue js route then you can get with window object. but if you are using vue js route then you can also get with route object. so it is a very simple way we can get current url.

I give you bellow both example, just see it and ut it those you require...


<!DOCTYPE html>



<title>How to get current URL in Vue JS?- HDTuto.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue"></script>



<div id="app">

{{ message }}


<script type="text/javascript">

var app = new Vue({

el: '#app',

data: {

message: 'Hello Vue!'


created: function(){

var currentUrl = window.location.pathname;







If you use $route


I hope you found your solution...

June 24, 2018 | Category : Vue.js
Related Posts

Blog Search