vue3-动态修改style

2021-12-02  本文已影响0人  PharkiLL
<template>
  <p @click="changeColor">hello</p>
</template>

<script setup>
import { reactive } from "vue"
const theme = reactive({
  color: 'red'
}) 
 const changeColor = ()=>{
  theme.color="black"
  console.log(theme);

}
</script>



<style scoped>
p {
  color: v-bind('theme.color');
}
</style>
上一篇下一篇

猜你喜欢

热点阅读