<router-link to="/test" tag="li" >测试1</router-link>
以上代码不生效,因为vue3.x版本对应的vue-router4.x版本已经不支持tag写法,以下写法替换
<router-link to="/home" custom v-slot="{ navigate }">
<li @click="navigate">首页</li>
</router-link>
虽然麻烦了一点点,但是更方便控制样式和结构了
<RouterLink to="/my" custom v-slot="{ navigate }">
<p class="item" @click="navigate">
<SvgIcon class="icon" name="my-user" width="20px" height="20px" />
个人中心
</p>
</RouterLink>