VUE如何实现单页面切换动画效果-创新互联
这篇文章主要介绍VUE如何实现单页面切换动画效果,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

代码如下:
// 视图切换动画逻辑
let history = window.sessionStorage
let historyCount = history.getItem('count') * 1 || 0
function routerTransition (to, from) {
const toIndex = history.getItem(to.name)
const fromIndex = history.getItem(from.name)
let direction = 'forward'
if (toIndex) {
if (toIndex >= fromIndex || !fromIndex) {
store.commit('UPDATE_DIRECTION', {direction})
} else {
direction = 'reverse'
store.commit('UPDATE_DIRECTION', {direction})
}
} else {
++historyCount
history.setItem('count', historyCount)
to.path !== '/' && history.setItem(to.name, historyCount)
direction = 'forward'
store.commit('UPDATE_DIRECTION', {direction})
}
}
router.beforeEach(function (to, from, next) {
routerTransition(to, from)
next()
})以上是“VUE如何实现单页面切换动画效果”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道!
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:VUE如何实现单页面切换动画效果-创新互联
网页链接:http://www.jxjierui.cn/article/dhgdhp.html


咨询
建站咨询
