hide query params in address bar - VueJS

独自空忆成欢 提交于 2019-12-11 06:43:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!