1.0.3 • Published 2 years ago

td-calendar v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

自定义右键菜单

TOC

参数

参数说明类型可选值默认值
options参数object{ el, data, beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, renderGrid, beforeDestroy, destroyed}

options说明

参数

参数说明类型可选值默认值
el渲染根节点HTMLElement | string
data见下
data
参数说明类型可选值默认值
value选择的时间datenew Date()
mode渲染模型string'year' |'month' |'day''day'

事件

事件名说明参数
beforeCreate创建实例前的回调函数
created创建实例后的回调函数—
beforeMount模板挂载前的回调函数
mounted模板挂载后的回调函数
beforeUpdate模板更新前的回调函数
updated模板更新后的回调函数
renderGrid自定义渲染的回调函数{date, el, mode}
beforeDestroy销毁前的回调函数
destroyed销毁后的回调函数

使用

CDN引入

<link rel="stylesheet" href="https://unpkg.com/td-calendar/lib/style/index.min.css">
<script src="https://unpkg.com/td-calendar/lib/index.min.js"></script>
new TdCalendar({
    el: '.calendar',
    data: {
        value: new Date(),
        mode: 'year'
    },
    beforeCreate() {
        console.log("实例创建前的回调");
    },
    created() {
        console.log("实例创建后的回调");
    },
    beforeMounte() {
        console.log("模板挂载前的回调");
    }
    mounted() {
        console.log("模板挂载后的回调");
    }
	beforeUpdate() {
        console.log("模板更新前的回调");
    }
	updated() {
        console.log("模板更新后的回调");
    }
    renderGrid(data) {
        console.log("自定义渲染,可返回jsx语法");
        const { date, el, mode } = data
        switch (mode) {
            case "year":
                return date.getFullYear()
                break;
            case "month":
                return date.getMonth() + 1 + "月"
                break;
            default:
                return date.getDate()
                break;
        }
    },
    beforeDestroy() {
        console.log("销毁前的回调");
    },
    destroyed() {
        console.log("销毁后的回调");
    }
})

image-20220211160238523

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago