问题
I'm using Vue.js 2 and I'm trying to create a link that should send me to another page. This is what I have:
<div v-for="u in myList">
<router-link :to="'/type/' + u.name"><a>{{u.name}}</a></router-link>
</div>
The above piece of code works but now I would like to pass a parameter (u.weight
for example ) along with this link.
I took a look at query parameters but I don't want the user to see this in the address bar type/productname/?queryparamshere
.
Is there a way to hide query params, or should I consider another way in order to achieve this?
回答1:
Just add the data to some store object and read it from that store in the next component.
The Vue Guide has an example about how to set up a simple store:
https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch
来源:https://stackoverflow.com/questions/40774131/hide-query-params-in-address-bar-vuejs