vue實現(xiàn)日歷表格(element-ui)
本文實例為大家分享了vue實現(xiàn)日歷表格的具體代碼,供大家參考,具體內(nèi)容如下
效果如圖:
html:后面的日期是循環(huán)出來的
<div class='calendar-title'> <span @click='lastDateclick'><</span> <span class='calendar-center'>近期事件</span> <span @click='nextDateclick'>></span></div><el-table ref='table't :data='filterData' border stripe> <el-table-column type='index' label='序號'></el-table-column> <el-table-column prop='code' label='代碼'> </el-table-column> <el-table-column prop='name' label='名稱'></el-table-column> <el-table-column v-for='(item,index) in dateArr' :key='index + item' :label='item'> <template slot-scope='scope'> <span v-html='dateInfoDesc(item,scope.row)'></span> </template> </el-table-column></el-table>
這里注意一下:key='index + item' ,之前我的key設置的只等于index,然后到了后面數(shù)據(jù)刪選的時候就各種出錯,找了半天,才發(fā)現(xiàn)是key值不唯一導致的!!
data:
bondList: [], // 獲取到數(shù)據(jù)組leftDate: '',rightDate: '',TempleftDate: '',TemprightDate: '',dateArr: []
js:
computed: { // 監(jiān)聽數(shù)據(jù)的日期滿足條件,則顯示該數(shù)據(jù) filterData() { var tableData = new Array(); var _this = this; this.dataList.filter(item => { if ( _this.dateArr.includes(item.startDate) || _this.dateArr.includes(item.endDate) || _this.dateArr.includes(item.refundDate) ) { tableData.push(item); } else { return; } }); return tableData; }}, methods: { // 顯示該數(shù)據(jù)在當前日期對應的描述內(nèi)容 dateInfoDesc(date, row) { var msg = ''; if (row.startDate == date) { msg = '起始日'; } else if (row.endDate == date) { msg = '結束日'; } else if (row.otherDate == date) { msg = '其他'; } return msg; }, // 獲取數(shù)據(jù) getDataList() { this.$axios.post(url).then(res => { this.dataList = res.data.data.rows; }); }, // 獲取日期數(shù)據(jù),返回的全是日期 getDateList() { var params = new URLSearchParams(); params.append('leftDate', this.leftDate); params.append('rightDate', this.rightDate); this.$axios({ method: 'post', url: `url2`, params: params }).then(res => { this.dateArr = res.data.data; //日期數(shù)據(jù) this.TempleftDate = this.dateArr[0]; // 該區(qū)間日期第一位 this.TemprightDate = this.dateArr[this.dateArr.length - 1]; // 該區(qū)間日期最后一位 this.leftDate = []; this.rightDate = []; }); }, // 上一區(qū)間的日期 lastDateclick() { this.leftDate = this.TempleftDate; this.getDateList(); }, // 下一區(qū)間的日期 nextDateclick() { this.rightDate = this.TemprightDate; this.getDateList(); }, }
有問題留言哈,希望能帶給你幫助。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關文章:
1. python實現(xiàn)讀取類別頻數(shù)數(shù)據(jù)畫水平條形圖案例2. python 如何停止一個死循環(huán)的線程3. Python編寫nmap掃描工具4. 如何基于python3和Vue實現(xiàn)AES數(shù)據(jù)加密5. PHP獲取時間戳等相關函數(shù)匯總6. ASP.NET MVC前臺動態(tài)添加文本框并在后臺使用FormCollection接收值7. 關于HTML5的img標簽8. Java 基于UDP協(xié)議實現(xiàn)消息發(fā)送9. python 爬取嗶哩嗶哩up主信息和投稿視頻10. php5.6不能擴展redis.so的解決方法
