Skip to content
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

v-bind:class with template string utilities not detected #785

Closed
rileychh opened this issue Mar 31, 2022 · 3 comments
Closed

v-bind:class with template string utilities not detected #785

rileychh opened this issue Mar 31, 2022 · 3 comments

Comments

@rileychh
Copy link

Summery

When I tried to bind a unocss class using template strings to an element, the class won't be detected.

Example code

main.js
import { createApp } from "vue";
import App from "./App.vue";
import "uno.css";

createApp(App).mount("#app");
App.vue
<script setup>
import { ref } from "vue";

const color = ref("blue");
</script>

<template>
  <div class="w-8 h-8" :class="[`bg-${color}`]"></div>

  <button @click="color = 'red'">Change color</button>
</template>
vite.config.js
import { defineConfig } from "vite";
import Vue from "@vitejs/plugin-vue";
import Unocss from "unocss/vite";
import { presetWind } from "unocss";

export default defineConfig({
  plugins: [
    Vue(),
    Unocss({
      presets: [presetWind()],
    }),
  ],
});
@kikyous
Copy link

kikyous commented Mar 31, 2022

This is expected behavior

@cll123456
Copy link

Summery

When I tried to bind a unocss class using template strings to an element, the class won't be detected.

Example code

main.js
App.vue

<script setup>
import { ref } from "vue";

const color = ref("blue");
</script>

<template>
  <div class="w-8 h-8" :class="[`bg-${color}`]"></div>

  <button @click="color = 'red'">Change color</button>
</template>

vite.config.js

@chenghsuanhe I think unocss can’t dynamic caculate generate class at present. but we use utilities full-name, it's be usefully.
image
image
image

@rileychh
Copy link
Author

rileychh commented Apr 2, 2022

Okay, since this is a expected behavior, I will close this issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants