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...
index.html
<!DOCTYPE html>
<html>
<head>
<title>How to get current URL in Vue JS?- HDTuto.com</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
},
created: function(){
var currentUrl = window.location.pathname;
console.log(currentUrl);
}
})
</script>
</body>
</html>
If you use $route
this.$route.query.page
I hope you found your solution...
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example