perf: 规范template模版中路由写法,不再使用$route$router,此写法vue-tsc编译不通过

This commit is contained in:
xiaoxian521
2023-05-12 13:01:59 +08:00
parent a1b8b27a1c
commit 1aba27590f
7 changed files with 27 additions and 12 deletions

View File

@@ -101,14 +101,14 @@ function onCloseTags() {
<el-button class="m-2" @click="onCloseTags">关闭标签</el-button>
<el-divider />
<el-button @click="$router.push({ name: 'Menu1-2-2' })">
<el-button @click="router.push({ name: 'Menu1-2-2' })">
跳转页内菜单传name对象优先推荐
</el-button>
<el-button @click="$router.push('/nested/menu1/menu1-2/menu1-2-2')">
<el-button @click="router.push('/nested/menu1/menu1-2/menu1-2-2')">
跳转页内菜单直接传要跳转的路径
</el-button>
<el-button
@click="$router.push({ path: '/nested/menu1/menu1-2/menu1-2-2' })"
@click="router.push({ path: '/nested/menu1/menu1-2/menu1-2-2' })"
>
跳转页内菜单传path对象
</el-button>
@@ -116,7 +116,7 @@ function onCloseTags() {
<el-divider />
<el-button
@click="
$router.push({
router.push({
name: 'Menu1-2-2',
query: { text: '传name对象优先推荐' }
})
@@ -126,7 +126,7 @@ function onCloseTags() {
</el-button>
<el-button
@click="
$router.push({
router.push({
path: '/nested/menu1/menu1-2/menu1-2-2',
query: { text: '传path对象' }
})
@@ -143,7 +143,7 @@ function onCloseTags() {
</el-link>
<el-divider />
<el-button @click="$router.push({ name: 'Empty' })">
<el-button @click="router.push({ name: 'Empty' })">
跳转无Layout的空白页面
</el-button>
</el-card>