Vue.jsで「A getter cannot have the same name as another state property. Rename one of them.」

今回はVue.jsを使っているときに「A getter cannot have the same name as another state property. Rename one of them.Found with “〇〇" in store “〇〇".」のようなwarningがChromeの開発者ツールのコンソールに出たときの対処法についてご紹介します。

Vue.jsのバージョンは3.5.0です。



Vue.jsで「A getter cannot have the same name as another state property. Rename one of them.」

結論を言うと、注意メッセージの通りで、warningの内容の通り、例えば冒頭の文章であれば「〇〇」の部分をリネームしましょう。

この場合、getterのメソッド名を変えることが一般的です。

例えば、下記のsample1.jsであればsample2.jsのようにしましょう。

・sample1.js

・sample2.js

終わりに

今回はVue.jsを使っているときに「A getter cannot have the same name as another state property. Rename one of them.Found with “〇〇" in store “〇〇".」のようなwarningがChromeの開発者ツールのコンソールに出たときの対処法についてご紹介いたしました。

最後までお読みいただきありがとうございます。
よろしければブログやTwitterでのシェアをお願いしております。
コメントもお待ちしております。
誤植や勘違いなどございましたらコメント欄にて教えていただけると幸いです。

直接契約ができるフリーランスエージェント「エンハンス」を立ち上げました。
詳しくは下記LPをご参照ください。
https://enhance.decryption.co.jp/

Youtubeチャンネル開設いたしました。
チャンネル登録者1000人を目指しているので、良いと思った方はチャンネル登録をお願いしたいです。
https://www.youtube.com/channel/UC219XhmSRxmXltTy6COxSMw






Vue.js

Posted by ちこ