首页 > 解决方案 > 这个 'v-if' 应该被移动到包装器元素(vue/no-use-v-if-with-v-for)

问题描述

使用 v-if 和 v-for 时出现 lint 错误。解决它的最佳方法是什么?

 <div>
   <input class="input is-static"
   type="text"
   v-model="userId"
   readonly
   v-if=" type === 'Admin'" />
   <div class="buttons">
     <button v-if="type !== 'Admin'"
     v-for="(option, index) in users" :key="index">
     {{ option }}
     </button>
    </div>
   </div>

标签: vue.js

解决方案


推荐阅读