Reputation: 2784
I've a list of Vue objects like this:
vue_objectname0,
vue_objectname1,
vue_objectname2 etc...
these object rae created by:
var vue_objectname0 = new Vue({
el: '#vue_objectname0',
data: {
seen: true,
}
})
from browser console I can correctly access data with:
vue_objectname0.seen
now I need to access the same data from a string as name of the object, how can I convert the string to the Object?
var name = "vue_objectname"+number;
console.log(name.seen);
this return "undefined"
Upvotes: 0
Views: 50
Reputation: 20845
All global variable can be accessed using the window
object as well.
window["vue_objectname"+number]
Upvotes: 1