I am working on a task list using Vue.js component and Laravel, with a button to mark each individual task as "complete" or "incomplete". At the moment I can't even get it to change state, let alone maintain it after the page refresh. The console log says [Vue warn]: Error in mounted hook: "TypeError: Assignment to read-only properties is not allowed in strict mode".
CompleteButton.vue
<template> <button type="button" @click="on_order_button_click()"> {{ buttonText }} </button> </div> </template> <script> export default { props: ['userId', 'item'], required: true, data() { return { item2: this.item } }, methods: { on_order_button_click() { this.item2.is_complete = !this.item2.is_complete; localStorage.setItem(this.item2.id, this.item2.is_complete); } }, mounted() { var storedState = localStorage.getItem(this.item2.id); if (storedState) { this.item2.is_complete = storedState; } }, computed: { buttonText() { return this.item2.is_complete === true ? "Completed" : "Incomplete"; } } }; </script> index.blade.php
<complete-button user-id="{{ $user->id }}" item="{{ $item}}"></complete-button>