我有一个复选框的数组,来自存储所有系统设置的主系统对象(getSystem{})。
在这个表单中,我正在访问一个用户,该用户具有角色数组[]。 如何将此角色数组与getSystem.user_roles进行检查?
我知道通常如何在javascript中做到这一点。 但是,从Vue.js角度来看,我应该在复选框输入中放什么?
<b-form-group>
<label for="company">Email Address</label>
<b-form-input type="text" id="email" v-model="user.email" placeholder="Enter a valid e-mail"></b-form-input>
</b-form-group>
// Here i can do user.roles to get the array of roles.
// What can I do to loop through the roles and check the box if it exists in the user roles??
<b-form-group v-for="resource, key in getSystem.user_roles" v-if="getSystem.user_roles">
<label>{{resource.role_name}}</label>
<input type="checkbox" [ what do I put here to compare against user.roles, and check the box if exists??] >
</b-form-group>
getSystem.user_roles
和user.roles
的模式,看起来是这样的<input type="checkbox" :checked="user.roles[resource.role_name]" >
? - Sphinx