1、在script中定义一个响应式变量
<script setup>
const colorValue = ref('blue')
</script>
2、在css中通过v-bind()绑定该变量
.textSty{
background-color: v-bind('colorValue');
}
3、在界面中可以使用该样式类,就可以动态改变背景颜色
<template>
<div style="width: 100px; height: 200px" class="textSty">测试css中通过v-bind绑定响应式变量</div>
</template>