2020-02-04 22:43:40 +08:00
|
|
|
# 固定头部
|
|
|
|
|
|
|
|
在展示大量数据的时候通过设定 `max-height` 来固定头部、滚动数据。
|
|
|
|
|
|
|
|
```html
|
|
|
|
<n-data-table
|
|
|
|
ref="table"
|
|
|
|
:columns="columns"
|
|
|
|
:data="data"
|
|
|
|
:pagination="pagination"
|
|
|
|
:max-height="250"
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
|
|
|
|
```js
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
key: 'name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
key: 'age'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Address',
|
|
|
|
key: 'address'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
const data = Array.apply(null, { length: 46 }).map((_, index) => ({
|
|
|
|
key: index,
|
|
|
|
name: `Edward King ${index}`,
|
|
|
|
age: 32,
|
|
|
|
address: `London, Park Lane no. ${index}`
|
|
|
|
}))
|
|
|
|
|
|
|
|
export default {
|
2020-10-08 00:13:35 +08:00
|
|
|
inject: ['message'],
|
2020-12-12 15:33:41 +08:00
|
|
|
data () {
|
2020-02-04 22:43:40 +08:00
|
|
|
return {
|
|
|
|
data,
|
|
|
|
columns,
|
|
|
|
pagination: {
|
|
|
|
pageSize: 15
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2020-12-12 15:33:41 +08:00
|
|
|
sendMail (rowData) {
|
2020-10-08 00:13:35 +08:00
|
|
|
this.message.info('send mail to ' + rowData.name)
|
2020-02-04 22:43:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|