New Sep 18, 2024

How to put json variable directly into DIV Class

Libraries, Frameworks, etc. All from Newest questions tagged vue.js - Stack Overflow View How to put json variable directly into DIV Class on stackoverflow.com

I need to change the color of a div element by a number that I assign in the script section. I am using Nuxtjs and tailwind.

This is the code what I want to work but sadly it doesn't. Anyone knows another way to get to the same result?

<template>
<div class = "bg-[ "{{color}}" ]">
</div>
</template>

<script> let color = 12345 </script>

So I am wondering is there a way to put a json Variable directly into the div class?

Scroll to top