Component 'transition' works pretty well with scoped styles, but when I try to use it with modular styles it doesn't work properly.
While researching, I found this thread: https://github.com/vuejs/vue-loader/issues/494
In this case, core vue developers suggest using the sass-loader features (&:global selector), but it doesn't work for me.
I use Nuxt and Vue2.
<template>
<div :class="$style.wrapper">
<button @click="visible ? visible = false : visible = true">
Show Text
</button>
<transition name="test">
<p v-show="visible">
Just Text
</p>
</transition>
</div>
</template>
<script>
export default {
name: 'IndexPage',
data () {
return {
visible: false
}
}
}
</script>
<style module lang="scss">
.wrapper {
&:global(-enter-active) { transition: opacity 1s; }
&:global(-leave-active) { transition: opacity 1s; }
&:global(-enter) { opacity: 0; }
&:global(-leave-to) { opacity: 1; }
}
</style>