搜索文档
query 传参
字符串写法
html
<router-link active-class="active" to="/home?title=Hello&time=2022-01-23">Home</router-link>对象写法
html
<router-link active-class="active" :to="{
path: '/home',
query: {
title: 'Hello',
time: '2022-01-23'
}
}">Home</router-link>query 接参
在 路由基本用法 中提到了路由组件新增的两个属性,一是 $route,二是 $router。
上一组件传递的参数位于路由组件的 $route 中。
接参一般是写在计算属性中的。
javascriptcomputed: { title(){ return this.$route.query.title }, time(){ return this.$route.query.time } }
