项目框架: vite
问题描述
在样式模块中设置了元素背景色:
<style scoped>
.box {
&.active {
background: rgba(95, 109, 255, .15);
}
}
</style>
PC端看着是正常的,有背景色,但是手机移动端没有
解决方法
解决方法1:
修改为以下代码后背景色正常展示:
.box.active {
background: rgba(95, 109, 255, .15);
}
解决方法2:
添加 - - - lang=“scss” ,添加之前确保安装了 sass,(使用 less 等其他的,依次类推,添加 lang=“使用的样式语法” )
<style scoped lang="scss">
.box {
&.active {
background: rgba(95, 109, 255, .15);
}
}
</style>
问题原因
原因:“&” 连接符没有生效