Skip to content

Commit 7f022e7

Browse files
committed
fix: 使用 router-link 进行左侧边栏的链接跳转
1 parent 74fea05 commit 7f022e7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/pages/home/components/LeftBar.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup name="LeftBar">
22
import { reactive, ref, onMounted } from "vue";
3-
import { useRouter } from "vue-router";
4-
import { toUrl } from "/src/utils/utils.js";
3+
import { useRouter, RouterLink } from "vue-router";
54
65
// 该变量将在左侧边栏组件加载时设定
76
// 记录有多少个分类可以被展开,由视图 (Viewport) 垂直高度决定
@@ -215,14 +214,14 @@ onMounted(() => {
215214
</div>
216215
<Transition name="menu">
217216
<ul class="py-[3px] flex nav-container" v-show="item1.show">
218-
<a
219-
@click.prevent="toUrl(item2.link)"
217+
<router-link
218+
:to="item2.link"
220219
v-for="item2 in item1.children"
221220
:key="item2.title"
222221
:href="item2.link"
223222
:class=" { 'bg-[#dcdcdc]': $route.path.trim().startsWith(item2.link.trim()) }"
224223
class="leading-4 navitem-flex hover:bg-[#dcdcdc] cursor-pointer pr-[10px] pl-[16px] block text-wrap select-none href-noline"
225-
>{{ item2.title }}</a>
224+
>{{ item2.title }}</router-link>
226225
</ul>
227226
</Transition>
228227
</div>

0 commit comments

Comments
 (0)