Skip to content

Instantly share code, notes, and snippets.

@stefanledin
Created November 14, 2017 10:21
Show Gist options
  • Select an option

  • Save stefanledin/ddce4bd24363a6b381e0e81fa20eaf0e to your computer and use it in GitHub Desktop.

Select an option

Save stefanledin/ddce4bd24363a6b381e0e81fa20eaf0e to your computer and use it in GitHub Desktop.
// Does not work! ๐Ÿ˜•
export default {
props: ['todo'],
data() {
const data = this.todo;
data.isComplete = false;
return data;
},
watch: {
isComplete: function(value) {
console.log(value + ' is updated');
}
}
}
// Does work! ๐Ÿ˜ƒ
export default {
props: ['todo'],
data() {
let data = {
isComplete: false
};
data = Object.assign({}, data, this.todo);
return data;
},
watch: {
isComplete: function(value) {
console.log(value + ' is updated');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment