Skip to content

14 - 动态CSS-模板中的写法 (Dynamic CSS- Writing in templates) #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tofu-Xx opened this issue Sep 15, 2024 · 1 comment
Closed

Comments

@Tofu-Xx
Copy link

Tofu-Xx commented Sep 15, 2024

<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
Copy link
Author

Tofu-Xx commented Sep 15, 2024

💌

@Tofu-Xx Tofu-Xx closed this as completed Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant