0👍
You need Object.keys
:
for (el in Object.keys(this.main_level))
If you need both the key and value, you can use Object.entries
:
for (el in Object.entries(this.main_level))
var data = {
main_level:
{
user_input_1 :
{
isFilled : false,
val_1 : null,
val_2 :null,
val_3 : null,
},
user_input_2 :
{
isFilled : false,
val_1 : null,
val_2 :null,
val_3 : null,
}
}
}
console.log(Object.keys(data.main_level))
- [Vuejs]-How to define the right Preset When using Nuxt in order to run on IE
- [Vuejs]-Filter Array by keyword
0👍
Your code is almost correct, just change the for-loop from in to of:
el in Object.values(this.main_level)
to el of Object.values(this.main_level)
Here is a working example:
methods: {
myclick: function () {
for (obj of Object.values(this.main_level)) {
console.log(obj)
}
}
}
Source:stackexchange.com