vue的開發中v-for報錯 [vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' directives.


vue 在 vscode 開發過程中報錯問題:

代碼:

<ul>
    <li v-for="author in articles">
      <img :src="author.images.medium" width="100">
      <br>
      <span v-text="author.title"></span>
    </li>
  </ul>

 

報錯信息:

[eslint-plugin-vue][vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' directives.

解決辦法:

這是因為安裝了ESLint插件,對vue進行了eslint檢查,只需將這個規則檢查屏蔽掉即可,具體操作如下: 
文件–》首選項–》設置–》在搜索框中輸入:vetur.validation.template–》找到vetur.validation.template:true–》將vetur.validation.template:true在右欄框中進行重置為false就ok了。 

[eslint-plugin-vue][vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' directives.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM