docs: [el-date-picker] add example of how to use prefix-icon (#4736)

This commit is contained in:
Alan Wang 2021-12-10 01:53:55 +08:00 committed by GitHub
parent 15251c3639
commit 82478eaaa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 0 deletions

View File

@ -130,6 +130,16 @@ date-picker/default-time
:::
## Set custom content of prefix
The content of prefix can be customized.
:::demo Setting `prefix-icon` to component which you import form other .vue or generated by the render function.
date-picker/custom-prefix-icon
:::
## Custom content
The content of cell can be customized, in scoped-slot you can get the cell data.

View File

@ -0,0 +1,39 @@
<template>
<div class="demo-date-picker">
<div class="block">
<span class="demonstration">set prefix-icon</span>
<el-date-picker
v-model="value1"
type="date"
placeholder="Pick a day"
:prefix-icon="customPrefix"
>
</el-date-picker>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, shallowRef, h } from 'vue'
export default defineComponent({
setup() {
const customPrefix = shallowRef({
render() {
return h('p', 'pre')
},
})
const state = reactive({
disabledDate(time) {
return time.getTime() > Date.now()
},
value1: '',
})
return {
...toRefs(state),
customPrefix,
}
},
})
</script>