[Vuejs]-Reference to DOM element in Vue,js component computed property

0👍

You should use method instead of computed property.

methods : {
  getUrl(className){
    switch(className) {
      case 'image1':
        //code..
        break
      case 'image2':
        //code...
        break
    }
  }
}

<template>
  <img :src="getUrl('image1')" class="image1"/>
  <img :src="getUrl('image2')" class="image2"/>
</template>

Leave a comment