【发布时间】:2021-12-31 04:49:53
【问题描述】:
组件“过渡”在作用域样式中效果很好,但是当我尝试将它与模块化样式一起使用时,它就不能正常工作了。
在研究过程中,我发现了这个帖子:https://github.com/vuejs/vue-loader/issues/494
在这种情况下,核心 vue 开发人员建议使用 sass-loader 功能(&:global 选择器),但它对我不起作用。
我使用 Nuxt 和 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>
【问题讨论】:
-
究竟是什么错误?
-
我的意思是“过渡”没有按预期工作
-
你读过关于过渡的 Vue 文档吗?
-
我当然读过,但是有一些使用范围样式转换的例子。如何将 transition 与 模块化样式 一起使用