[Vuejs]-Replacing a reference to an observable array in Vue

0๐Ÿ‘

A working JSFiddle might be helpful here, but Iโ€™m guessing that you could fix it by using:

demo.$set("items", demo.items.filter(function (item) {
return item.childMsg.match(/Hello/)
})

0๐Ÿ‘

You can use this function to remove observable proto from objects and arrays.

const clone = (value) => {
  if (!value) return value;
  const isObject = (typeof value === 'object');
  const isArray = Array.isArray(value);
  if (!isObject && !isArray) return value;
  // Removing reference of Array of values
  if (isArray) return [...value.map(val => clone(val))];
  if (isObject) return { ...value };
  return value;
};

Leave a comment