0

In vue it's easy to change the class of an element dynamically. However, what I want to do has nothing to do with that:

I have an attribute color with the value #333 for example. Now I want to build a css class like:

.myColorClass > a {
  color: this.color;
}

It's not possible for me to style every single element a individually with the style attribute. So how do I approach this problem with Vue?

Hillcow
  • 890
  • 3
  • 19
  • 48
  • Can you check this and see if this helps you (https://www.w3schools.com/css/tryit.asp?filename=trycss3_var) – Himanshu Dec 12 '19 at 11:41
  • @Himanshu doesn't help, because the variable still is declared in css. – Hillcow Dec 12 '19 at 12:02
  • directly accessing the value from the data to the css isn't possible. From what I can understand, you want to add a particular style to all the anchor tags then why not to create a class containing color and just use javascript to add it to all the anchor tags. – Himanshu Dec 12 '19 at 12:11
  • I found the answer right here: https://stackoverflow.com/a/46553407/6399812 – Hillcow Dec 12 '19 at 12:19
  • 1
    Does this answer your question? [VueJS - v-bind:style + hover](https://stackoverflow.com/questions/46551925/vuejs-v-bindstyle-hover) – Hillcow Dec 12 '19 at 12:19
  • I feel like the particular solution would be a lot of work for you to just attain the styling of the anchor tag. But I don't know the exact part that you're trying to solve. See whichever solution works best for you and use the same. – Himanshu Dec 12 '19 at 12:42

0 Answers0