1. 程式人生 > >iview 表格插入圖片,並獲取圖片對應資料

iview 表格插入圖片,並獲取圖片對應資料

 首先通過attr為標籤新增屬性,屬性值為對應圖片下標index;

然後在on裡邊通過e.target點選事件獲取點中的標籤,然後獲取屬性uid對的值,傳參

{
                title: '一審修改',
                key: 'oneshen',
                render: (h, params) => {
                    // console.log(params.row)
                    let list = params.row.dlist;
                    let arr=[]
                    for(let i in list){
                        arr.push( [
                            h('img', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                attrs: {
                                    src: params.row.list[i].photo, uid : i , style: "width: 100px;height: 100px;"						
                                },
                                style: {
                                },
                                on: {
                                    click: (e) => {
                                        let id = e.target.getAttribute("uid");
                                        this.firstshen(params.index,id);
                                    }
                                }
                            }),
                       ])
                    }
                    return h('div', {
                       
                    },

                   arr);
              }
            },

 其次通過函式接收表格對應行的id和點選圖片的index

firstshen (index,id) {
         let arr = this.data1[index].dlist
        
        
},