I have an object that looks like this, and I can push data using below method. Also I initialize the types data.
myObj = {
1: ["a", "b", "c"],
2: ["c", "d", "e"],
}
data: {
types: {}
},
methods: {
pushValue(key, value) {
var obj = this.types
if (obj.hasOwnProperty(key)) {
var idx = $.inArray(value, obj[key]);
if (idx == -1) {
obj[key].push([value]);
}
} else {
this.$set(obj, key, [value]);
}
},
}
It works fine.
However, now I want my object to look like this:
myObj = {
1: {
"a": [
[],[]
],
"b": [
[],[]
],
}
}
How can I modify my append function to append the elements like this?
"a" => [ ... ]and I don't quite know where exactly do you want to push your value in the new output usingpushValue@changeon checkboxes.@change, push value is triggeted with key: 1 or 2, value: a,b,c, etc. And I edited obj to myObj for not confusing it with the one within the method"myObj.1.a?? And is there relationship betweenthis.typesandmyObj? Because I don't seemyObjhas anything to do withpushValue.:nameattributes of child componentmyObj.1.athen? I mean, what will be pushed into the empty arrays? The numbers 1 or 2, or the keys a, b, c, ...? Because when you executepushValues, you are modifyingthis.types, notmyObj. Even at this moment I still don't quite know what's the point ofmyObj. Or you just want to append an array with two empty arrays inside tomyObj.1.a??