You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/date-picker/demo/date-render.md

53 lines
1.3 KiB

7 years ago
<cn>
#### 定制日期单元格
7 years ago
使用 `dateRender` 可以自定义日期单元格的内容和样式。
</cn>
7 years ago
<us>
#### Customized Date Rendering
7 years ago
We can customize the rendering of date cells in the calendar by providing a `dateRender` function to `DatePicker`.
</us>
7 years ago
```html
<template>
7 years ago
<div>
<a-date-picker>
<template slot="dateRender" slot-scope="current, today">
<div class="ant-calendar-date" :style="getCurrentStyle(current, today)">
{{current.date()}}
</div>
</tempalte>
</a-date-picker>
<a-range-picker>
<template slot="dateRender" slot-scope="current">
<div class="ant-calendar-date" :style="getCurrentStyle(current)">
{{current.date()}}
</div>
</tempalte>
</a-range-picker>
<a-week-picker>
<template slot="dateRender" slot-scope="current">
<div class="ant-calendar-date" :style="getCurrentStyle(current)">
{{current.date()}}
</div>
</tempalte>
</a-week-picker>
7 years ago
</div>
</template>
<script>
export default {
methods: {
getCurrentStyle(current, today) {
const style = {};
if (current.date() === 1) {
style.border = '1px solid #1890ff';
style.borderRadius = '50%';
}
return style
}
}
}
</script>
```