element-ui使用v-for来遍历el-radio - 学习记录帖

<el-form-item label="员工性别" label-width="1rem" prop="sttusCodes">
  <el-radio-group v-model="radio" @change="onRadioChange">
      <el-radio :label="item.value" :key="item.value" v-for="item in form.basicInfo.sttusCodes">{{item.label}}</el-radio>
  </el-radio-group>
</el-form-item>
export default {
  data() {
    return {
      imgSrc: "../../static/images/tx.jpg",
      radio: "1",
      form: {        
          sttusCodes: [
            {
              label: "男",
              value: "0",
              selected: "1"
            },
            {
              label: "女",
              value: "1",
              selected: "0"
            }
          ],
    }
  },
  methods: {
      onRadioChange(item) {
      console.log("item", item);
    }
  }
}

你可能感兴趣的:(vue,element-ui,vue的学习和整理)