[Vuejs]-Vue.js – how to update JSON?

0👍

If you want to add a column to a row, you should pass the row to addModule(). Shouldn’t you?
Also, I pass the $index to know at which position to insert the new column:

<button v-on:click="addModule(row, $index, $event)">Add</button>

then all you have to do is splice() the new object into the row’s _children array.

methods: {
    addModule: function(row, colIndex, e) {
        var newCol = { type: 'col', size: 1 }
        row._children.splice(colIndex, 0, newCol)
        //or to insert to the right:
        row._children.splice(colIndex + 1, 0, newCol) 
    }
}

Leave a comment