vue-route之params、query

需求:一个列表页,通过列表点击进入详情页,因为是tab页,同时不想同时打开多个详情

$route.params

类型: Object

一个 key/value 对象,包含了动态片段和全匹配片段,如果没有路由参数,就是一个空对象。

<router-link

              class="title"

              :to="{'name':'topicVisualDetail',params: { 'id': scope.row.topic_id, 'time': scope.row.data_time.slice(0,10)}}"

            >{{ scope.row.title }}</router-link>

这个会打开不同的tab页:

/topicVisualDetail/c1554647257_197/2019041112

同时route配置里要这么写:

topicVisualDetail/:id/:time

$route.query

类型: Object

一个 key/value 对象,表示 URL 查询参数。例如,对于路径 /foo?user=1,则有 $route.query.user == 1,如果没有查询参数,则是个空对象。

<router-link

              class="title"

              :to="{'name':'topicVisualDetail',query: { 'id': scope.row.topic_id, 'time': scope.row.data_time.slice(0,10)}}"

            >{{ scope.row.title }}</router-link>

/topicVisualDetail?id=c1554647257_197&time=2019041112

这里在使用的时候,切换tab会导致参数丢失,bug早就修复了:

https://github.com/PanJiaChen/vue-element-admin/pull/765/commits/b21b38e2110c3901a7152802406e97ef2a7c8dc4

https://github.com/PanJiaChen/vue-element-admin/pull/1090/commits/3a343fa70d272b5578b64828324539a7e393812d#diff-e1682bd637a49ef5798601911b05ef7f 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容