mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-01 02:37:46 +08:00
docs: [el-date-picker] add example of how to use prefix-icon (#4736)
This commit is contained in:
parent
15251c3639
commit
82478eaaa0
@ -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.
|
||||
|
39
docs/examples/date-picker/custom-prefix-icon.vue
Normal file
39
docs/examples/date-picker/custom-prefix-icon.vue
Normal 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>
|
Loading…
Reference in New Issue
Block a user