描述:
// message.vue
<template>
<li v-for="m in messageList" :key="m.id">
<router-link
:to="{ name: 'Detail', query: { id: m.id, title: m.title } }"
>{{ m.title }}</router-link
>
<button @click="pushShow(m)">push 查看</button>
</li>
<hr />
<router-view></router-view>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
import { useRoute, useRouter } from "vue-router";
let messageList = [
{ id: "004", title: "message004" },
{ id: "005", title: "message005" },
{ id: "006", title: "message006" },
];
const router = useRouter();
const pushShow = (m: { id: string; title: string }) => {
router.push({ name: "Detail", query: { id: m.id, title: m.title } });
};
</script>
<style scoped lang="less"></style>
// detail.vue
<template>
<li v-for="m in messageList" :key="m.id">
{{ m.title }}
</li>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useRoute } from "vue-router";
let messageList = reactive([
{ id: "001", title: "message001" },
{ id: "002", title: "message002" },
{ id: "003", title: "message003" },
]);
const route = useRoute();
</script>
<style scoped lang="less"></style>
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.