我正在尝试学习 Vue.js 并进行基本的淡入淡出。我有一个始终留在页面上的链接列表。单击链接时,我希望淡入和淡出div
. 默认情况下div
是看不到的。这div
包含几个组件。我试图按照文档进行操作。但是,该元素仅在离开时淡出,而在进入时则没有任何反应。我删除了本文档的多余部分并保留了相关元素。
<template>
<div class="list">
<ul>
<li @click="openWindPoetry">☞ Wind Poetry</li> // button that toggles div show
</ul>
</div>
<div style="width: 97%;" class="project container">
<transition name="fade" mode="out-in">
<div v-if="showWP" class="backdrop" @scroll.passive="handleScroll"> // div needed to transition
<Header theme="WP" header="Wind Poetry" :types="['Interaction','Data Visualisation','2020']"></Header>
<BodyText theme="WP" heading="ABOUT"
body="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nulla magna, consectetur quis tellus eget, ultricies mattis nisi. Duis dictum dolor in ante placerat, non ultricies dui faucibus. Vivamus lobortis sapien porttitor, molestie urna ut, varius neque. In eu dapibus lectus. Etiam consequat, massa ut consequat lacinia, velit dui molestie dolor, id dapibus sem justo a ante. In pellentesque, odio ut pharetra congue, quam tellus efficitur arcu, non mattis risus nibh ac turpis.">
</BodyText>
<div class="introImg">
<video alt="GIF DEMO" loop autoplay="autoplay" src="./assets/wind/wind_poetry-demo-1.mp4"></video>
</div>
</transition>
</div>
</template>
<script>
export default {
name: "App",
components: {
Header,
Gradient,
BodyText
},
data() {
return {
title: "LIST OF WORKS",
ProjTitle: "Wind Poetry",
showWP: false
};
},
methods: {
openWindPoetry() {
(this.title = "BACK TO HOME"),
(this.showWP = true),
(this.showRec = false);
}
}
}
</script>
<style>
#app {
font-family: "Roboto Mono";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.5s ease-out;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
</style>