iview table表格內容爲數組或者對象的子元素時問題討論

正常狀況下,iview框架table表格內容只需配置好 key 就OK,數組

稍微複雜點就是用一個reder函數進行操做(params.row 爲本行數據)框架

 

 。iview

以上問題都很好解決,無需太動腦筋。函數

開發中遇到需求就是表格某一格內容不能直接獲取,必須從數組中遍歷出全部name,而且每一個name配以惟一id,點擊name時經過id跳轉傳參ui

後臺返回數據以下spa

 

 一、首先要把把name和id 進行拆分配對code

function customStyleList(row){
    var nameList=row.styleName.split(",")
    var nameIDList=row.id.split(",")
    var styleList=[]
    for(let i=0;i<nameList.length;i++){
        arr={name:nameList[i],id:nameIDList[i]}
        styleList.push(arr)
    }   
    return styleList  //此時組件一個有值數組
}
二、render 函數裏循環 styleList 數組

 

 OK完美解決component

效果以下blog

 

 

 

參考iview官方IPA  https://www.iviewui.com/components/table開發

相關文章
相關標籤/搜索