datepickervue-componentvuejs3element-plus

Vue 3 datepicker Element-Plus


Im currently trying to display price (loaded via an api) under the days of a datepicker (a bit like google flights).

Exemple: enter image description here

Im currently using Vue 3. Im trying to acheive this using Element-plus library. I can't find a way how to do it. Any suggestion (i checked Element-plus doc), or suggestion may another Vue 3 lib does exactly the same !

Here's my code

<link href="//unpkg.com/element-plus/lib/theme-chalk/index.css" rel="stylesheet" type="text/css"/>
<script src="//unpkg.com/vue@next"></script>
<script src="//unpkg.com/element-plus/lib/index.full.js"></script>
<div class="grid-container-medium">
    <div id="app">
        <div class="d-flex justify-content-between">
            <div class="block"><span class="demonstration">Single</span>
                <el-date-picker :default-value="new Date(2021, 6, 28)"
                                placeholder="Pick a date"
                                type="date"
                                :disabled-date="disabledDate"
                                v-model="value1"></el-date-picker>
            </div>
        </div>
    </div>
</div>
<script>
    var Main = {
        data() {
            return {
                value1: '',
                value2: '',
                disabledDate(time) {
                    return time.getTime() < Date.now()
                },
            };
        }
    };
    ;const app = Vue.createApp(Main);
    app.use(ElementPlus);
    app.mount("#app")
</script>

Solution

  • In the last version of Element+ (v1.2.0-beta.1) they have added a new #cell slot in the DatePicker component.

    Docs: DatePicker - Custom content

     <template #default="cell">
        <div class="cell" :class="{ current: cell.isCurrent }">
          <span class="text">{{ cell.text }}</span>
          <span v-if="isHoliday(cell)" class="holiday"></span>
        </div>
      </template>
    

    Screenshot of Custom content slot

    So, you can do it now with Element+ also.