一个vue的日历组件

一个vue calendar的npm组件

说明:

1.基于element-ui开发的vue日历组件。

地址

更新:

1.增加value-format指定返回值的格式
2.增加头部插槽自定义头部

<ele-calendar >
 <template slot-scope="slotProps">
   {{ slotProps.todo}}
 </template>
</ele-calendar >
todo="{'yearLabel':'年','month':'月','event':[prevYear,prevMonth,nextYear,nextMonth]}"
event为切换年月是调用事件

3.增加日期多选 :selectionMode="'dates'",事件select返回选择日期及节点
4.增加语言切换 :lang="'en'"
5.抽离css方便自定义样式 import 'ele-calendar/dist/vue-calendar.css' //引入css

注释:需要配置了jsx依赖

使用方法:

1.下载npm包:
你的VUE项目的根目录底下运行:
    npm install ele-calendar
2.引入本npm包并注册为vue的组件:
例如:在需要使用的vue页面中:
    <template>
        
        <!-- 里面写eleCalendar组件-->
            <ele-calendar
                  :render-content="renderContent"
                  :data="datedef"
                  :prop="prop"
            ></ele-calendar>
    </template>
    
    <script>
    import eleCalendar from 'ele-calendar'
    import 'ele-calendar/dist/vue-calendar.css' 
    export default {
        data(){
            return{
                datedef:[
                    {"date":"2018-06-30","content":null,"cid":null},
                    {"date":"2018-06-26","content":null,"cid":null},
                ],
                prop:'date' //对应日期字段名
            }
        },
        components: {
            eleCalendar
        },
        methods: {
          renderContent(h,parmas) {
            const loop = data =>{
              return (
                data.defvalue.value ? (<div><div>{data.defvalue.text}</div> 
                <span  >备选项</span>
                </div>) : <div>{data.defvalue.text}</div>
              )
           }
           return (
            <div  style="min-height:60px;">
             {loop(parmas)}
            </div>
            );
         },
       }
    }
    </script>
3.通过render-content的渲染Function 自定义日历显示内容
例如:
    renderContent(h,parmas) { //设置lunarcalendar=true,parmas返回值包含农历
                const loop = data =>{
                  return (
                    data.defvalue.value ? (<div><div>{data.defvalue.text}</div> 
                    <span  >备选项</span>
                    </div>) : <div>{data.defvalue.text}</div>
                  )
               }
               return (
                <div  style="min-height:60px;">
                 {loop(parmas)}
                </div>
                );
             },
       parmas返回当前日期和传入data对应内容

Calendar Attributes

参数说明类型可选值默认值
data显示的数据array
prop对应日期字段名string
lang语言切换stringenzh-CN
value-format绑定值的格式。不指定则绑定值为 Date 对象stringyyyy-MM-dd
selectionMode日历模式stringdatesday
highlight是否要高亮对应日期booleanfalse
currentmonth高亮选中日期booleanfalse
disabledDate设置禁用状态,参数为当前日期,要求返回 BooleanFunction
border是否带有边框booleanfalse
lunarcalendar是否需要农历booleanfalse
defaultValue默认展示某月Date
render-content内容区的渲染 FunctionFunction(h, parmas)

Calendar Events

事件名说明参数
date-change切换日历年、月data
select选择日期的数组及节点val,selectDom
pick点击日历返回当前点击时间data、event、row、dome

Scoped Slot

name说明
自定义头的内容,参数为 {'yearLabel':'年','month':'月','event':[prevYear,prevMonth,nextYear,nextMonth]}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值