Is there a way to access the DOM element that initiated a method inside a Vue component computed property?
For example:
<template>
<img :src="getUrl" class="image1"/>
<img :src="getUrl" class="image2"/>
</template>
<script>
export default {
computed: {
getUrl() {
// Need reference to the DOM element and obtain its className..
switch(className) {
case 'image1':
// Code for image1...
break
case 'image2':
// Code for image2...
break
}
}
}
}
</script>
NOTE: Printing 'this' inside the method did not provide any helpful information...
Thank you :)