vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

14 - 动态CSS-模板写法(Dynamic CSS- template writing)

Open Tofu-Xx opened this issue 5 months ago • 0 comments

<script setup>
import { ref } from "vue"
const theme = ref("red")

const colors = ["blue", "yellow", "red", "green"]

setInterval(() => {
  theme.value = colors[Math.floor(Math.random() * 4)]
}, 1000)

</script>

<template>
  <p :style="`color:${theme}`">hello</p>
</template>

Tofu-Xx avatar Sep 15 '24 17:09 Tofu-Xx