<markdown>
# 自定义样式

列：在列对象上设定 `className` 属性为确定的列设定 class。
</markdown>

<script lang="ts" setup>
interface RowData {
  key: number
  name: string
  age: number
  address: string
}

const data: RowData[] = [
  {
    key: 0,
    name: 'John Brown',
    age: 32,
    address: 'New York No. 1 Lake Park'
  },
  {
    key: 1,
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park'
  },
  {
    key: 2,
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park'
  }
]

const columns = [
  {
    title: 'Name',
    key: 'name'
  },
  {
    title: 'Age',
    key: 'age',
    className: 'age'
  },
  {
    title: 'Address',
    key: 'address'
  }
]

function rowClassName(row: RowData) {
  if (row.age > 32) {
    return 'too-old'
  }
  return ''
}
</script>

<template>
  <n-data-table
    :columns="columns"
    :data="data"
    :row-class-name="rowClassName"
  />
</template>

<style>
:deep(.too-old td) {
  color: rgba(255, 0, 0, 0.75) !important;
}
:deep(.age) {
  color: rgba(0, 128, 0, 0.75) !important;
}
:deep(.too-old .age) {
  color: rgba(0, 0, 128, 0.75) !important;
}
</style>
