0
.lightTheme
クラスを追加して、#app
の背景を黒から白にフェードインするためにCSSトランジションプロパティを使用しようとしています。 .lightTheme
クラスの追加は期待通りに機能しますが、移行は行いません。クラス変更時のVue.js CSSトランジション
Vue transition elementを追加する必要がありますか?そしてもしそうなら、どのように? #app
は、DOMを入力/残されていない - 私はちょうどそれがプロパティ(だアニメーション化したいと私は、可能な場合は、不要なコードを追加する必要はありません
HTML
<div id="app" v-bind:class="{ lightTheme: isActive }">
<button v-on:click="toggleTheme">Change theme</button>
</div>
JS
!new Vue({
el: '#app',
data: {
isActive: false
},
methods: {
toggleTheme: function(){
this.isActive = !this.isActive;
// some code to filter users
}
}
});
CSS
#app {
background: black;
transition: 1s;
}
#app.lightTheme {
background: white;
}
ありがとうございます!