[Vuejs]-Best way to conditionally apply utility classes on a component based on its props

0👍

You could move all the logic to computed property:

function getBtnClass () {
  let classes = []
  if (this.theme === 'primary') classes.push('Bdc(color1)', 'Bdc(color2):h')
  ...
  return classes.join(' ')
}

And pass it to the template: <div class='getBtnClass'>...</div>

Leave a comment