Incorporated within my page is a vue.js item that monitors modifications made to a form. The code for this functionality is as follows:
var changes_applied = [];
var changes_applied_block = new Vue({
name: "ChangesApplied",
el: '#changes-applied',
data: {
items: changes_applied
},
methods: {
remove: function(index) {
changes_applied.splice(index, 1);
}
}
});
Whenever a change is detected, it gets added to the changes_applied
array and displays in the "Changes Applied" section as expected. The removal process also functions correctly by invoking the remove
method on the vue object.
In addition, there's a separate "clear" button that does not relate to the vue instance. Upon clicking this button, the data source is reset to an empty array using changes_applied = [];
The issue arises after clearing the data with the button. Subsequent modifications or additions to the changes array no longer reflect in the vue component—almost like the vue element is no longer linked to the changes_applied
array.
Should there be additional bindings or steps required for proper synchronization, or is there a prescribed "vue way" to reset the vue data without direct manipulation of the source array?