vue 报错Duplicate keys detected: ‘1’. This may cause an update error.

出现这个原因的报错是因为下拉框的key值不是唯一的

 <FormItem label="学校" prop="schoolName">
          <Select v-model="showEditForm.schoolId" placeholder="Select your school">
            <Option v-for="schoolNameId in schoolNameIds" :label="schoolNameId.schoolName"
                    :value="schoolNameId.schoolId" :key="schoolNameId.schoolId">
              {{schoolNameId.schoolName}}
            </Option>
          </Select>
        </FormItem>

:key="schoolNameId.schoolId 必须是唯一的才行

Logo

前往低代码交流专区

更多推荐