成功el-checkbox-group选择一个其它全选解决

<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="form.username" />
      </el-form-item>
      <el-form-item label="城市" prop="cityds">
        <el-checkbox-group v-model="form.cityds">
          <el-checkbox v-for="city in cities" :label="city" :key="city">{{
            city
          }}</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item style="text-align: center">
        <el-button type="primary" @click="return_list_page()"
          >返回列表</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getInfo } from "@/api/test";
export default {
  data() {
    return {
      cities: ["北京", "上海", "深圳"],
      form: {
        cityds: [],
      },
    };
  },
  mounted() {
    var id = this.$route.query.id;
    this.loadData(id);
  },
  methods: {
    return_list_page() {
      this.$router.push("/test_list");
    },
    loadData(id) {
      getInfo(id).then((result) => {
        var _data = result.Data;
        this.form = Object.assign({}, _data);
      });
    },
  },
};
</script>

(0)

相关推荐