【转】如何在iview表格中使用select标签

图例

粘贴图片

实现方法

参数功能

参数 功能描述
style 样式
props 绑定数值以及一些api设置
on 绑定相关方法,例如点击事件

api具体值设置以及相关方法请参考 https://www.iviewui.com/components/select#API

代码块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
          title: "企业名称",
          key: "enterpriseId",
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "Select",
                {
                  style: {
                  },
                  props: {
                    value: this.groupData[params.index].enterpriseId,
                    placement: "top",
                    filterable: true,
                    clearable: true,
                    allowCreate: true
                  },
                  on: {
                    "on-change": event => {
                      this.groupData[params.index].enterpriseId = event;
                      params.row.enterpriseId = event;
                      this.ShowCompanyInfo(params.row, params.index);
                    },
                    "on-create": event => {
                      this.addEnterprise(event);
                    }
                  }
                },
                this.enterpriseList.map((item, itemIndex) => {
                  return h(
                    "Option",
                    {
                      props: {
                        value: item.id,
                        key: item.id
                      }
                    },
                    item.name
                  );
                })
              )
            ]);
          }
        }
 
注意

循环option的时候不要用forEach,forEach在render函数中不起作用,此处应用map。

 
原文地址:https://www.cnblogs.com/cyqdeshenluo/p/12176302.html