Skip to content

Instantly share code, notes, and snippets.

@antoniojps
Created May 9, 2017 21:06
Show Gist options
  • Save antoniojps/0d132d7d7b73b96f1a7ebdaa727d29e2 to your computer and use it in GitHub Desktop.
Save antoniojps/0d132d7d7b73b96f1a7ebdaa727d29e2 to your computer and use it in GitHub Desktop.
// This will render the same result. We can also bind to a computed property that returns an object. This is a common and powerful pattern:
// HTML
<div v-bind:class="classObject"></div>
// JS
data: {
isActive: true, error
:
null
}
,
computed: {
classObject: function () {
return {active: this.isActive && !this.error, 'text-danger': this.error && this.error.type === 'fatal',}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment