When I was writing a function of Vue using Element-UI, I encountered a problem. After checking for a while, I found the cause and recorded it
The code for the page is as follows
<el-checkbox-group v-model="form.roleIds">
<el-checkbox v-for="item in roleList" v-bind:key="item.id" :label="item.id">{{item.name}}</el-checkbox>
</el-checkbox-group>
Copy the code
The following error occurs
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined"
found in
---> <ElCheckbox> at packages/checkbox/src/checkbox.vue
<ElCheckboxGroup> at packages/checkbox/src/checkbox-group.vue
<ElFormItem> at packages/form/src/form-item.vue
<ElCol>
<ElRow>
<ElForm> at packages/form/src/form.vue
<ElDialog> at packages/dialog/src/component.vue
<UserEdit> at src/views/common/authority/user-edit.vue
<SystemRole> at src/views/common/authority/user.vue
<EleEmptyLayout> at node_modules/ele-admin/packages/ele-empty-layout/src/main.vue... (1 recursive calls)
<EleProLayout> at node_modules/ele-admin/packages/ele-pro-layout/src/main.vue
<EleLayout> at src/layout/index.vue
<App> at src/App.vue
<Root>
Copy the code
RoleIds in v-model=”form.roleIds” does not default to array in form