vue route query传参
一、传参页面,需要传id、title、content三个参数
<ul>
<li v-for="news in newsList" :key="news.id">
<!--/news/detail-->
<RouterLink :to="{
path:'/news/detail',
query:{
id:news.id,
title:news.title,
content:news.content
}}">{{news.title}}</RouterLink>
</li>
</ul>
二、接收参数页面
<script setup lang="ts" name="About">
import {useRoute} from 'vue-router'
let route = useRoute()
</script>
<template>
<ul class="news-list">
<li>编号:{{ route.query.id }}</li>
<li>标题:{{ route.query.title }}</li>
<li>内容:{{ route.query.content }}</li>
</ul>
</template>