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 ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example