「Vue.js&Nuxt.js超入門」という書籍を用いてVue.js を学習しています。
Vueファイルを以下のように記述しているのですが、"localStorage is not defined" という表記が出てしまいました。
created: function(){ var items = localStorage.getItem('log'); var logs = JSON.parse(items); if (logs != null) { this.result = logs; } }, methods: { appAction: function(exp, res) { this.result.unshift([exp, res]); if(this.result.length > 10){ this.result.pop(); } var log = JSON.stringify(this.result); localStorage.setItem('log', log); } }
元から導入されている機能だと思うのですが、どこかで定義しなおさないといけないのでしょうか?
何卒よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/22 00:11