调用后端获取节假日列表信息然后Vue渲染到前端列表
【“魔镜”系列】节假日信息
格式
存储在数据库中,包含日期、名字、所属节假日、休息天数、是否为节假日、是否为向前调休等字段
显示
封装成了个Vue插件,调用后端获取节假日信息然后显示到列表中,具体代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <template> <div> <div style="border:1px solid #FFFFFF;width: 310px;margin-left: 0;margin-bottom: 5px"/> <ul v-for="(timor,index) in timorList" :key="timor" style="width: 310px;margin-left: 0;padding-left: 0px"> <li v-if="index < 12" style="font-family:'BebasNeueRegular',Arial,Helvetica,sans-serif;text-shadow: 0 0 5px #00c6ff;color: #fff;font-size: 23px;"> <span>{{timor.name}}</span> <span style="float: right">{{timor.date}}</span> </li> <div v-if="index <11" style="border:0.5px dashed #666666;width: 100%;"/> </ul> </div> </template>
<script> import { getList } from '@/api/timor'
export default { name: "Timor", data() { return { timorList: [], query: { current:1, size:20 } } }, methods:{ getData(){ getList(this.query).then(res => { // this.timorList = res.holiday; if(res.code === 0){ for(let holiday in res.data.records){ let timor = { name:res.data.records[holiday].name, date:res.data.records[holiday].date.substring(0, 10) }; this.timorList.push(timor) } } }); } }, mounted() { this.getData(); } } </script>
<style scoped> li { list-style-position: inside; list-style-image: url('/icon.png'); } </style>
|
未来版本
我来手动更新节假日信息显然不太可能,我可没那些时间,有个免费获取节假日信息的API,后续会接入,网址如下:提莫的神秘商店
此为博主副博客,留言请去主博客,转载请注明出处:https://www.baby7blog.com/myBlog/78.html