<template>
<div>
<div class="box"></div>
</div>
</template>
<script setup lang='ts'>
const myColor = ref('green')
</script>
<style scoped lang='scss'>
.box{
width: 200px;
height: 200px;
border: 1px solid #ccc;
background-color: v-bind(myColor);
transition: all 1s;
}
</style>
09-07
1447
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-17
1310
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)