本文主要是介绍【无标题】Vue3想在scss中想使用动态的变量,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Vue3想在css中想使用动态的变量
首先在组件中定义 :style="{ '--custom-style-color': customStyle.color }",customStyle.color就是那个传过来的变量,也可以是自定义的-color 值
const props = defineProps({customStyle: {type: Object,default: () => ({}),},
});const color = ref('#00ff44');
然后在scss中使用:
.el-select-dropdown__item.selected {color: var(--custom-style-color) !important; // 使用 CSS 变量}
var(--custom-style-color)就是那个可以使用的变量了。
这篇关于【无标题】Vue3想在scss中想使用动态的变量的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!