在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ iview的table組件,如何根據(jù)某一個列中的狀態(tài)變換不同的字體顏色?

iview的table組件,如何根據(jù)某一個列中的狀態(tài)變換不同的字體顏色?

clipboard.png
我想根據(jù)不同的狀態(tài)來改變不同的顏色,該如何做,用的iview框架。
每次用這些框架的時候都會被table中的一些小問題難到····

回答
編輯回答
我不懂

列接受一個 render prop
https://iview.github.io/compo...

2018年8月6日 04:37
編輯回答
神經(jīng)質(zhì)

現(xiàn)在OK了。我的寫法是

{
                        title: '審核狀態(tài)',
                        key: 'state',
                        render:(h,params)=>{
                          let tmpStr = "";
                          if(params.row.state==0){
                            tmpStr="未通過";
                          }else if(params.row.state==1){
                            tmpStr="已通過";
                          }else{
                            tmpStr="正在審核";
                          }
                          return h('span',{
                              style:{
                                 color: (params.row.state==0)?"#ed3f14":(params.row.state==1?"#19be6b":"#2d8cf0")
                              }
                          },tmpStr)
                        }
                    }
2018年3月6日 23:42
編輯回答
情未了
render (row, column, index) {
    return
     `<i-button type="primary" size="small" @click="show(${index})">查看</i-button> <i-button type="error" size="small" @click="remove(${index})">刪除</i-button>`;
    }

iview官網(wǎng)的栗子,render函數(shù)中渲染你想要的樣式,不過按照你的需求是需要一個span就行 你可以在data中聲明一個方法,按照你傳過來的row.xx的值來返回對應(yīng)的顏色,用style或者class綁定都可以
給你看一下我用element的代碼,大同小異的

<template slot-scope="scope">
    <el-tag
      :type="stateTagType(scope.row.state)"
      size="mini">{{scope.row.state}}</el-tag>
  </template>

template 相當(dāng)于render函數(shù)。

stateTagType(type) {
  if(type == "已發(fā)起") {
    return "warning"
  }else if(type == "已超時") {
    return "danger"
  }else if(type == "已完成") {
    return "success"
  }
}

methods中的方法

2017年7月15日 08:07
編輯回答
拮據(jù)
render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'success',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '10px'
                                    },
                                    on: {
                                        click: () => {
                                         
                                        }
                                    }
                                }, '置頂'),
                                h('Button', {
                                    props: {
                                        type: 'warning',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '10px'
                                    },
                                    on: {
                                        click: () => {
                                           
                                        }
                                    }
                                }, '編輯'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '10px'
                                    },
                                    on: {
                                        click: () => {
                                            
                                        }
                                    }
                                }, '結(jié)束活動'),
                            ]);
                        }
2018年4月27日 23:31