最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Nuxt transition not working on diffents layouts - Stack Overflow

programmeradmin1浏览0评论

I'm using Nuxt for my new website, and I create a CSS transition with page-enter-active class, but it's only working on the pages based on the default layout.

A simple demo of the problem : /

When browsing from or to the home page (based on a different layout), there's no transition. But if you navigate from team page to about, you can see it.

The code of the demo :

Thanks a lot for your help

I'm using Nuxt for my new website, and I create a CSS transition with page-enter-active class, but it's only working on the pages based on the default layout.

A simple demo of the problem : https://test-transition-layout.netlify.com/

When browsing from or to the home page (based on a different layout), there's no transition. But if you navigate from team page to about, you can see it.

The code of the demo : https://github.com/KevinFuret/test-template-transition

Thanks a lot for your help

Share Improve this question asked Sep 17, 2018 at 14:05 Kévin FuretKévin Furet 3451 gold badge8 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

You're very close! All you're missing are the classes for layoutTransitions in your CSS (https://nuxtjs.org/api/configuration-transition#the-layouttransition-property).

Nuxt separates the two because page transitions are more granular and may need more specific body adjustments between shared page layouts. As layout transitions happen at a higher/parent level than pages, the page transitions are dependent on their behavior.

Update to assets/main.css

.page-enter-active,
.page-leave-active,
.layout-enter-active, 
.layout-leave-active {
  transition: opacity .5s
}

.page-enter,
.page-leave-active,
.layout-enter, 
.layout-leave-active {
  opacity: 0
}

Demo: https://kevinfuret-test-template-transition.glitch.me/

Source: https://glitch.com/edit/#!/kevinfuret-test-template-transition

发布评论

评论列表(0)

  1. 暂无评论