P
P
phpForeve2017-05-13 20:55:37
JavaScript
phpForeve, 2017-05-13 20:55:37

Navigating through pages with the get parameter. How to implement in vue.js?

There is a page with a search on it. After pressing the "search" button, the parameter ?search='search string' is passed to the string.
Nothing happens. We put the cursor in the address bar of the browser, press enter - Voule, the search was successful (I mean that the search works).

<router-link  :to="{name: 'index-page',  query: {search: search}}">Найти</router-link>

An important point, nothing happens if we stay on the same route. If you switch to another route at the same time, everything works great.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Kulakov, 2017-05-13
@kulakoff Vue.js

There is no route change, so the router is silent. When you place the cursor and press enter, the browser forces the page to load at the specified path. And it seems that the logic for working with request parameters is sitting somewhere in the component life cycle hooks and they do not work in your version.

T
Timofey, 2017-05-13
@mr_T

This is what should solve the problem. There are examples with path parameters, but it should work with query too. In any case, if beforeRouteUpdate doesn't work, then watch $route will definitely work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question