鍍金池/ 問(wèn)答/HTML/ 怎么才能寫(xiě)復(fù)雜的iView的table columns?

怎么才能寫(xiě)復(fù)雜的iView的table columns?

iView的Table的columns 數(shù)據(jù)的key,怎么才能是對(duì)象下面的數(shù)據(jù)呢?

我的意思是:



  columns8: [
            {
                "title": "Name",
                "key": "name",
                "fixed": "left",
                "width": 200
            },
            {
                "title": "Show",
                "key": "show",
                "width": 150,
                "sortable": true,
            ...

一般來(lái)說(shuō)這個(gè)key是一個(gè)字符串,像上面這樣.
傳遞數(shù)據(jù)的時(shí)候,我們傳遞table的data,像這樣:

<table :data=data_list>                

data_list 為下面這樣:

 [
      {
        name: 'a',
        show: 'hello a',
        ...  
      },
      {
        name: 'b',
        show: 'hello b',
        ...  
      },
      {
        name: 'c',
        show: 'hello c',
        ...  
      }
    ]

但是,我有一個(gè)需求就是:

如果data_list像這樣:

         
 [
      {
        name: 'a',
        obj: { show: 'hello a', }
        ...  
      },
      {
        name: 'b',
        obj: { show: 'hello b', }
        ...  
      },
      {
        name: 'c',
        obj: { show: 'hello c', }
        ...  
      }
    ]

這樣應(yīng)該怎么寫(xiě)table的 columns呢?

回答
編輯回答
舊言

得到數(shù)據(jù)后,轉(zhuǎn)化成iview的table所需要的格式

2017年5月19日 03:14
編輯回答
還吻

render函數(shù),

{
    title: 'Show',
    key: 'Show',
    align: 'center',
    render: (h, params) => params.row.obj.show
}
2018年1月27日 18:49