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 Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?
- Angular 9 Image Upload with Crop Example
- Files Upload on Button Click in PHP Dropzone Example
- PHP Dropzone Allow only One File to Upload Example
- PHP Dropzone Allow only Images to Upload Example
- PHP Dropzone Delete Uploaded File Example
- Livewire CRUD Laravel 7 Example