iview实现单选框

1、template

2、data

data() {
    return {
      nowid: 0,
      uuid: '',
      columns1: [
        {
            
            width: 60,
            align: 'center',
            title: '选择',
            render: (h, params) => {
                console.log(params);
                let id = params.row.id;
                let flag = false;
                if (this.nowid === id) {
                    flag = true
                } else {
                    flag = false
                }
                let that = this;
              return h('div', [
                h('Radio', {
                  props: {
                    value: flag
                  },
                  on: {
                    'on-change': () => {
                      that.nowid = id;
                      this.uuid = params.row.uuid;
                      console.log(this.uuid);
                    }
                  }
                })
              ])
            },
        },
        {
          title: "名称",
          key: "name"
        },
        {
          title: "年龄",
          key: "age"
        },
    };
  },

 

你可能感兴趣的:(Vue,iview)