Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

:class bind with multiple arguments

I’m trying to add a class to my bind however im getting an error on the "+ animation" its saying : is expected, how do i go about getting that class

class="animation__placeholder"
:class="{
  'animation__placeholder--' + animation,
  'animation__placeholder--top':(alignment === 'top'),
  'animation__placeholder--center':(alignment === 'center'),
  'animation__placeholder--bottom':(alignment === 'bottom'),
  'animation__placeholder--right':(side === 'right'),
  'animation__placeholder--center':(side === 'center'),
  'animation__placeholder--left':(side === 'left'),
}"

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In your code, you’re doing things complex. Here is the simpler one.

new Vue({
  el: '#app',
  data() {
    return {
      animation: 'fade-out',
      alignment: 'center',
      side: 'right'
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">
  <section 
    class="animation__placeholder"
    :class="`
      animation__placeholder--${animation}
      animation__placeholder--${alignment}
      animation__placeholder--${side}
    `"
  >Devtools</section>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading