# td-calendar

> 日历

Latest version **1.0.3** (published 2022-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install td-calendar
pnpm add td-calendar
yarn add td-calendar
bun add td-calendar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-02-11 |
| First published | 2022-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 157.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tandee |
| Maintainers | tandee |
| Keywords | 日历 |

## Links

- npm: https://www.npmjs.com/package/td-calendar
- npm.io page: https://npm.io/package/td-calendar

## Recent versions

- 1.0.3 (latest) — 2022-02-11
- 1.0.2 — 2022-02-11
- 1.0.1 — 2022-02-11
- 1.0.0 — 2022-02-10

## README

# 自定义右键菜单



[TOC]

## 参数

| 参数    | 说明 | 类型   | 可选值                                                       | 默认值 |
| ------- | ---- | ------ | ------------------------------------------------------------ | ------ |
| options | 参数 | object | { el, data, beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, renderGrid, beforeDestroy, destroyed} | —      |



### options说明

#### 参数

| 参数 | 说明                   | 类型   | 可选值        | 默认值 |
| ---- | ---------------------- | ------ | ------------- | ------ |
| el   | 渲染根节点 | HTMLElement \| string | — | —      |
| data | 见下     | — | —            | — |



##### data

| 参数  | 说明       | 类型   | 可选值                   | 默认值     |
| ----- | ---------- | ------ | ------------------------ | ---------- |
| value | 选择的时间 | date   | —                        | new Date() |
| mode  | 渲染模型   | string | 'year' \|'month' \|'day' | 'day'      |



#### 事件

| 事件名        | 说明                  | 参数             |
| ------------- | --------------------- | ---------------- |
| beforeCreate  | 创建实例前的回调函数  | —                |
| created       | 创建实例后的回调函数— | —                |
| beforeMount   | 模板挂载前的回调函数  | —                |
| mounted       | 模板挂载后的回调函数  | —                |
| beforeUpdate  | 模板更新前的回调函数  | —                |
| updated       | 模板更新后的回调函数  | —                |
| renderGrid    | 自定义渲染的回调函数  | {date, el, mode} |
| beforeDestroy | 销毁前的回调函数      | —                |
| destroyed     | 销毁后的回调函数      | —                |



## 使用

### CDN引入


```html
<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>
```


```js
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](https://qiniudns.tannde.com//typora/202202111602247.png)

---
_Source: https://npm.io/package/td-calendar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
