wangzhibo
6 天以前 7bd866831780abcf5a59c4cbb7d1be456eea7c99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
    <div class="page">
        <el-descriptions title="动态路由参数" border :column="1">
            <el-descriptions-item label="ID">{{ $route.params.id || '-' }}</el-descriptions-item>
            <el-descriptions-item label="Name">{{ name || '无' }}</el-descriptions-item>
        </el-descriptions>
 
        <div class="op">
            <el-button @click="toLink(1)">链接1</el-button>
            <el-button @click="toLink(2)">链接2</el-button>
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { random } from 'lodash-es';
import { useCool } from '/@/cool';
 
const props = defineProps({
    id: String,
    name: String
});
 
const { router } = useCool();
 
function toLink(n: number) {
    switch (n) {
        case 1:
            router.push(`/demo/test/route/${random(100)}/神仙都没用`);
            break;
 
        case 2:
            router.push(`/demo/test/route/${random(100)}`);
            break;
    }
}
</script>
 
<style lang="scss" scoped>
.page {
    background-color: var(--el-bg-color);
    padding: 10px;
 
    :deep(.el-descriptions__label) {
        width: 100px;
    }
 
    .op {
        margin-top: 20px;
    }
}
</style>