Skip to main content
deleted 38 characters in body
Source Link
kissu
  • 47.3k
  • 16
  • 94
  • 197

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration.
  • Lastly the $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready, i.e. it's called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 
<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration.
  • Lastly the $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready, i.e. it's called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration.
  • Lastly the $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready, i.e. it's called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 
improved grammar and formatting
Source Link
YakovL
  • 8.4k
  • 13
  • 74
  • 117

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration  .
  • Lastly they $routethe $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready document.ready, i.ie itse. it's called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration  .
  • Lastly they $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready , .ie its called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration.
  • Lastly the $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready, i.e. it's called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 
copy paste of the comment as part of the code
Source Link
Yordan Georgiev
  • 5.5k
  • 2
  • 60
  • 58

More detailed answer to help the newbies of VueJs.VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration .
  • Lastly they $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready , .ie its called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJs.

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 

More detailed answer to help the newbies of VueJS:

  • First define your router object, select the mode you seem fit. You can declare your routes inside the routes list.
  • Next you would want your main app to know router exists, so declare it inside the main app declaration .
  • Lastly they $route instance holds all the information about the current route. The code will console log just the parameter passed in the url. (*Mounted is similar to document.ready , .ie its called as soon as the app is ready)

And the code itself:

<script src="https://unpkg.com/vue-router"></script> var router = new VueRouter({ mode: 'history', routes: [] }); var vm = new Vue({ router, el: '#app', mounted: function() { q = this.$route.query.q console.log(q) }, }); 
added src for vue router
Source Link
Sabyasachi
  • 1.6k
  • 14
  • 22
Loading
deleted 2 characters in body
Source Link
Sabyasachi
  • 1.6k
  • 14
  • 22
Loading
Source Link
Sabyasachi
  • 1.6k
  • 14
  • 22
Loading