Routing parameters of Vue page parameters

Method 1: Passing parameters with params is not visible in the url. Note that passing parameters with params needs to pass the name defined in router index.js, namely name:'Parameter',
Insert picture description here

页面一:
<router-link :to="{ path: '/Parameter',name: 'Parameter',params: { pc: pcNumnow } }"><li class="nav-list">参数管理</li></router-link>
//pcNumnow是页面一定义的一个变量
页面二:
var b=this.$route.params.pc//b的值就为页面一pcNumnow的值
//要注意的是 用params传参 如果页面二刷新了,参数就不在了

Method 2: Use query to pass parameters, this is visible in the routing

页面一:
<router-link :to="{ path: '/Parameter',query: { pc: pcNumnow } }"><li class="nav-list">参数管理</li></router-link>
页面二:
var b=this.$route.query.pc

Guess you like

Origin blog.csdn.net/GongWei_/article/details/110393488