query传值
使用query,页面刷新不会存在问题,也不需要在路由中配置。
{ path:'/detail', component: detail, }
使用方法:
传递参数(JS中):
this.$router.push({ path: '/detail', query:{key: item.id} });
传递参数(页面中):
<router-link :to="{ path:'/detail', query: {key: item.id} }"><button>显示<button></router-link> <router-link :to="`/detail?id=${item.id}`"><button>显示</button></router-link>
获取参数:
this.$route.query.key
url的表现形式(url中带有参数):
http://localhost:8080/detail?key=1

浙公网安备 33010602011771号