element日歷calendar組件上月、今天、下月、日歷塊點(diǎn)擊事件及模板源碼
辰小白小白最近在寫(xiě)日歷模板,項(xiàng)目已經(jīng)用了element組件,奈何element日歷組件官方文檔提供的資料實(shí)在太少了。所以這里希望有相關(guān)開(kāi)發(fā)需要的朋友能夠少走一些辰小白踩過(guò)的坑。
首先展示一些模板效果圖:
這個(gè)項(xiàng)目的詳細(xì)介紹可以下辰小白的這篇文章:后端開(kāi)發(fā)的福音,vue+element實(shí)現(xiàn)的vue-element-admin前臺(tái)框架,開(kāi)箱即用
下面是日歷模板首頁(yè)源碼
<template> <div> <el-card class="_calendar"> <el-container> <el-main> <el-card> <el-calendar v-model="value" :first-day-of-week="7"> <!-- 這里使用的是 2.5 slot 語(yǔ)法,對(duì)于新項(xiàng)目請(qǐng)使用 2.6 slot 語(yǔ)法--> <template slot="dateCell" slot-scope="{date, data}"> <div slot="reference" class="div-Calendar" @click="calendarOnClick(data)"> <p :class="data.isSelected ? 'is-selected' : ''"> {{ data.day.split('-').slice(1).join('-') }} <i :class="[data.isSelected ?'el-icon-check':'']" ></i> <i v-if="_.indexOf(isArrange, data.day)>0" class="el-icon-s-claim"></i> <!-- <i class="el-icon-coffee-cup"></i> --> </p> </div> </template> </el-calendar> </el-card> </el-main> <el-aside width="40%" style="overflow: hidden;"> <el-card> <div class="el-calendar__header"> <div class="el-calendar__title">排班詳情</div> <div class="el-calendar__button-group"> <div class="el-button-group"> <button type="button" class="el-button el-button--plain el-button--mini" @click="saveOnClick" > <span>新增</span> </button> </div> </div> </div> <div class="calendar-info"> <div style="padding: 15px;"> <div role="alert" class="el-alert el-alert--success is-dark" @click="infoOnClick"> <i class="el-alert__icon el-icon-success is-big"></i> <div class="el-alert__content"> <span class="el-alert__title is-bold">2020-06-19 9:00~11:00</span> <p class="el-alert__description">值班人員:張三、李四、王五</p> <p class="el-alert__description">攜帶設(shè)備:123547、985431、745481</p> <i class="el-alert__closebtn el-icon-close" @click.stop="infoDel"></i> </div> </div> <div role="alert" class="el-alert el-alert--info is-dark" @click="infoOnClick"> <i class="el-alert__icon el-icon-info is-big"></i> <div class="el-alert__content"> <span class="el-alert__title is-bold">2020-06-19 9:00~11:00(待審核)</span> <p class="el-alert__description">值班人員:張三、李四、王五</p> <p class="el-alert__description">攜帶設(shè)備:123547、985431、745481</p> <i class="el-alert__closebtn el-icon-close"></i> </div> </div> <div role="alert" class="el-alert el-alert--warning is-dark" @click="infoOnClick"> <i class="el-alert__icon el-icon-warning is-big"></i> <div class="el-alert__content"> <span class="el-alert__title is-bold">警告提示的文案</span> <p class="el-alert__description">文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明</p> <i class="el-alert__closebtn el-icon-close"></i> </div> </div> <div role="alert" class="el-alert el-alert--error is-dark" @click="infoOnClick"> <i class="el-alert__icon el-icon-error is-big"></i> <div class="el-alert__content"> <span class="el-alert__title is-bold">錯(cuò)誤提示的文案</span> <p class="el-alert__description">文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明文字說(shuō)明</p> <i class="el-alert__closebtn el-icon-close"></i> </div> </div> </div> </div> </el-card> </el-aside> </el-container> </el-card> <calendarDrawer ref="calendarDrawer"></calendarDrawer> <calendarForm ref="calendarForm"></calendarForm> </div> </template> <script> import calendarDrawer from "./calendar-drawer.vue"; import calendarForm from "./calendar-form.vue"; export default { components: { calendarDrawer, calendarForm }, data: function() { return { value: new Date(), isArrange: [ "2020-06-08", "2020-06-09", "2020-06-10", "2020-06-11", "2020-06-17", "2020-06-18" ] }; }, created: function() { this.$nextTick(() => { // 點(diǎn)擊前一個(gè)月 let prevBtn = document.querySelector( ".el-calendar__button-group .el-button-group>button:nth-child(1)" ); prevBtn.addEventListener("click", e => { console.log(this.data); this.$notify({ title: "上一月", message: "上個(gè)月頭天:" + this.value, type: "success", position: "top-left" }); }); //點(diǎn)擊下一個(gè)月 let nextBtn = document.querySelector( ".el-calendar__button-group .el-button-group>button:nth-child(3)" ); nextBtn.addEventListener("click", () => { console.log(this.value); this.$notify({ title: "下一月", message: "下個(gè)月頭天:" + this.value, type: "warning", position: "top-left" }); }); //點(diǎn)擊今天 let todayBtn = document.querySelector( ".el-calendar__button-group .el-button-group>button:nth-child(2)" ); todayBtn.addEventListener("click", () => { this.$notify.info({ title: "今天", message: "今天:" + this.value, position: "top-left" }); }); }); }, mounted: function() {}, methods: { //點(diǎn)擊日期塊 calendarOnClick(e) { console.log(e); // this.isArrange.push("2020-06-19"); this.$notify.error({ title: "日歷塊點(diǎn)擊", message: e, position: "top-left" }); }, //點(diǎn)擊信息塊 infoOnClick() { this.$refs.calendarDrawer.drawer = true; }, //新增排班 saveOnClick() { this.$refs.calendarForm.dialogFormVisible = true; }, //刪除排班 infoDel() { this.$confirm("此操作將永久刪除該排班, 是否繼續(xù)?", "提示", { confirmButtonText: "確定", cancelButtonText: "取消", type: "warning" }) .then(() => { this.$message({ type: "success", message: "刪除成功!" }); }) .catch(() => { this.$message({ type: "info", message: "已取消刪除" }); }); } } }; </script> <style scoped> .is-selected { color: #1989fa; } .p-popover { text-align: center; } ._calendar { height: 99.5%; width: 100%; } .el-main { padding: 0px; overflow: hidden; } .calendar-info { height: 94%; overflow: auto; } .el-alert { margin: 15px 0px; } .el-alert:hover { transform: scale(1.02); } .el-alert:active { transform: scale(1.01); } </style> <style > ._calendar .div-Calendar { height: 125px; box-sizing: border-box; padding: 8px; } ._calendar .el-calendar-table .el-calendar-day { padding: 0px; height: 125px; } ._calendar .el-container, ._calendar .el-calendar { height: 100%; } ._calendar .el-card__body { padding: 0px; } </style>
具體的幾個(gè)點(diǎn)擊事件都有備注,這里不細(xì)說(shuō)了
到此這篇關(guān)于element日歷calendar組件上月、今天、下月、日歷塊點(diǎn)擊事件及模板源碼的文章就介紹到這了,更多相關(guān)element calendar組件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解vuex中的this.$store.dispatch方法
這篇文章主要介紹了vuex中的this.$store.dispatch方法,必須要用commit(‘SET_TOKEN’,?tokenV)調(diào)用mutations里的方法,才能在store存儲(chǔ)成功,需要的朋友可以參考下2022-11-11淺談在Vue.js中如何實(shí)現(xiàn)時(shí)間轉(zhuǎn)換指令
這篇文章主要介紹了淺談在Vue.js中如何實(shí)現(xiàn)時(shí)間轉(zhuǎn)換指令,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-01-01記一次Vue中$route序列號(hào)報(bào)錯(cuò)
本文主要介紹了記一次Vue中$route序列號(hào)報(bào)錯(cuò),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04vue中父子組件傳值,解決鉤子函數(shù)mounted只運(yùn)行一次的操作
這篇文章主要介紹了vue中父子組件傳值,解決鉤子函數(shù)mounted只運(yùn)行一次的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07@vue/cli4.x版本的vue.config.js常用配置方式
這篇文章主要介紹了@vue/cli4.x版本的vue.config.js常用配置方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-05-05vue實(shí)現(xiàn)頁(yè)面div盒子拖拽排序功能
本文主要介紹了vue實(shí)現(xiàn)頁(yè)面div盒子拖拽排序功能,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10Vue + Echarts頁(yè)面內(nèi)存占用高的問(wèn)題解決方案
點(diǎn)擊左側(cè)的菜單可以切換不同的看板,有些看板頁(yè)面中的報(bào)表比較多,用戶(hù)多次切換后頁(yè)面的內(nèi)存占用可以上升為GB級(jí),嚴(yán)重時(shí)導(dǎo)致頁(yè)面內(nèi)存溢出,使得頁(yè)面崩潰,極大影響了用戶(hù)體驗(yàn),本文給大家介紹Vue + Echarts頁(yè)面內(nèi)存占用高的問(wèn)題解決方案,感興趣的朋友一起看看吧2024-02-02Vue實(shí)現(xiàn)過(guò)渡效果的基本方法
Vue 提供了一個(gè)強(qiáng)大的過(guò)渡系統(tǒng),可以用于在進(jìn)入、離開(kāi)和列表渲染時(shí)添加各種動(dòng)畫(huà)效果,這些過(guò)渡不僅能夠提升用戶(hù)體驗(yàn),還能使界面更加生動(dòng)和吸引人,本文將介紹 Vue 中實(shí)現(xiàn)過(guò)渡效果的基本方法,并提供使用 setup 語(yǔ)法糖的代碼示例,需要的朋友可以參考下2024-09-09nuxt.js服務(wù)端渲染中axios和proxy代理的配置操作
這篇文章主要介紹了nuxt.js服務(wù)端渲染中axios和proxy代理的配置操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-11-11