router-link过渡效果
时间: 2023-09-14 14:03:02 浏览: 93
在Vue中,router-link是用来生成导航链接的组件,它最后会被转换成a标签。要实现router-link的过渡效果,可以使用Vue的过渡动画来实现。首先,在router-link上添加一个transition标签,并设置name属性为"fade",然后在<style>标签中定义.fade-enter-active、.fade-leave-active和.fade-enter类名的过渡效果,如下所示:
```html
<transition name="fade">
<router-link to="/myInfo">新页面打开myInfo页</router-link>
</transition>
<style>
.fade-enter-active, .fade-leave-active {
transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
</style>
```
这样就可以给router-link添加过渡效果了。在这个例子中,定义了一个名为fade的过渡动画,当router-link进入或离开时,会通过opacity属性来实现淡入淡出的效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Vue学习笔记(六)--- 前端路由 Vue Router](https://blog.csdn.net/weixin_45092437/article/details/120842075)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [react-router-dom 简明教程](https://blog.csdn.net/IT_bar/article/details/117002395)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文