Vue JS add class dynamically

PHOTO EMBED

Wed Dec 22 2021 16:28:12 GMT+0000 (UTC)

Saved by @mmerkley #html

// demo is a class that is needed anyway and then boxASelected is added if true
:class="{active: boxASelected}"

// Or pass this into a computed property
:class="{boxAClasses}"

computed: {
  boxAClasses() {
    return { active: this.boxASelected };
  }
}
content_copyCOPY