46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import router from "@/router";
|
|
import { ElButton } from "element-plus";
|
|
import { useTagsViewStore } from "@/stores";
|
|
|
|
export default defineComponent({
|
|
name: "ToDetail",
|
|
/**
|
|
* 组件初始化:渲染两个跳转详情的按钮
|
|
*/
|
|
setup() {
|
|
const route = useRoute();
|
|
const tagsViewStore = useTagsViewStore();
|
|
|
|
/**
|
|
* 跳转详情
|
|
*/
|
|
const navigateToDetail = async (id: number) => {
|
|
await router.push({
|
|
path: "/detail/" + id,
|
|
query: { message: `msg${id}` },
|
|
});
|
|
// 更改标题
|
|
tagsViewStore.updateTagName(route.fullPath, `详情页缓存(id=${id})`);
|
|
};
|
|
return () =>
|
|
h("div", null, [
|
|
h(
|
|
ElButton,
|
|
{
|
|
type: "primary",
|
|
onClick: () => navigateToDetail(1),
|
|
},
|
|
{ default: () => "跳转详情1" },
|
|
),
|
|
h(
|
|
ElButton,
|
|
{
|
|
type: "success",
|
|
onClick: () => navigateToDetail(2),
|
|
},
|
|
{ default: () => "跳转详情2" },
|
|
),
|
|
]);
|
|
},
|
|
});
|