1

I would like to do something like the following:

addGreenClass(elHrefName) {
      var inputElement = document.getElementById(this.$refs.elHrefName.id);
      console.log(inputElement);
}

The variable 'elHrefName' in this case is just a passed on string containing the string form of the actual ref value that is being referenced in the vue $ref object. I'm not sure how to convert a string variable being passed on in function to be then utilized as part of a dom reference, in this case a dom reference in the Vue.js $refs property.

Simon Suh
  • 10,599
  • 25
  • 86
  • 110
  • 2
    Just use the object syntax, surely? `this.$refs[elHrefName].id` – Botje Oct 14 '17 at 08:41
  • I realized why this question wasn't previously gone into depth here. I can just pass on the element ID lol! for some reason i had it in my head that i had to use $refs from my lack of programming abilities. Found out i can just pass on the element ID and my function works perfectly fine. No need to delve into Vue.js $refs definitions just let, had my fingers tingling to use it's functionality tho. Anyways, problem solved for now, time to work on my next app feature. :) – Simon Suh Oct 14 '17 at 14:07

0 Answers0