A
A
Artur Galyaev2020-11-16 19:03:05
Vue.js
Artur Galyaev, 2020-11-16 19:03:05

How to use query in Vue?

I am, for example, on /filter, I change something in the filters and it redirects me:

created() {
    this.$store.watch(
      (state) => (state.filter.settings),
      () => {
      		$router.push({name: "planner", query: {
        			"color": this.settings.color
        		}})
        this.$store.dispatch('filter/GET')
      },
      {
        		deep:true
      	})
  },

But I can’t get data from the query in the store, how to solve this problem?

Doing this doesn't help:
beforeRouteEnter(to,from,next) {
    $router.query = to.query
                next()
  },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-11-16
@art5455

Why not pass an argument to the action?

this.$store.dispatch('filter/GET', {query: this.$route.query})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question