el-select多选 但是选择了全部就不能选择其他的选项

博客主要围绕el-select组件展开,提到其在多选模式下,若选择了全部选项,就不能再选择其他选项的情况,涉及前端开发中组件的使用问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

el-select多选 但是选择了全部就不能选择其他的选项

      <el-form-item label="限制平台:" prop="platform_id">
          <el-select
            v-model="formData.platform_id"
            filterable
            clearable
            multiple
            placeholder="请选择"
            class="w-300"
            @change="handlePlat"
          >
            <el-option label="全平台通用" value="0"></el-option>
            <el-option
              v-for="(item, key) in plats"
              :key="key"
              :label="item.name"
              :value="String(item.id)"
              :disabled="item.disabled"
            ></el-option>
          </el-select>
          <div class="ml20">通用表示:全部平台</div>
        </el-form-item>
 handlePlat() {
      // console.log(this.formData.platform_id);
      // console.log(this.formData.platform_id.indexOf("0"));
      if (this.formData.platform_id.indexOf("0") == "-1") {
        this.plats.map((res) => {
          res.disabled = false;
        });
      } else {
        this.plats.map((res) => {
          res.disabled = true;
        });
        this.formData.platform_id = ["0"];
      }
    },```