美文网首页预约tool
【微信小程序】日历视图组件

【微信小程序】日历视图组件

作者: 扮鬼之梦 | 来源:发表于2021-04-22 18:04 被阅读0次

组件介绍

日历展示功能


日期点击功能


git地址

https://gitee.com/gnliscream/calendar-view

软件架构

使用微信小程序自定义组件开发

小程序自定义组件官网:https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html

使用说明

目录结构

使用步骤

1.下载组件源代码,放入小程序里自己定义的组件文件夹(例如/components)

2.创建需要调用日历视图组件的界面(例如/pages/image)

3.全局引入calendar-view组件

4.参数

<calendar-view config="{{calendarConfig}}" color="#4ec4c8" title="日历视图" bind:click ="calendarViewDetailShow"></calendar-view>

config: 日历显示范围和选中状态配置

this.setData({
  calendarConfig: {
    selectedDates: [ // 选中日期列表
        {
            "date": "2021-03-01", // 选中的日期
            "bottom": "2小时", // 选中日期下方文字
            "top": "1节课", // 选中日期上方文字
            "list": [] // 点击日期时会返回的参数,参数名和参数值可任意
        },
        {
            "date": "2021-03-29",
            "bottom": "2小时",
            "top": "1节课",
            "list": [{
                "creator": "1331255738911162368",
                "createTime": "2021-03-29 18:54:16",
                "updateTime": "2021-03-29 18:54:27",
                "deleted": false,
                "courseRecordId": "1376487868398043136",
                "studentId": "1330535521876705280",
                "courseDuration": 2,
                "startTime": "2021-03-29 18:30:00",
                "endTime": "2021-03-29 20:30:00",
                "remark": "比例三"
            }]
        }
    ],
    startDate: "2021-03-01", // 开始日期
    endDate: "2021-04-22" // 结束日期
  }
})

color: 选中日期背景色(可使用#rgb或者颜色英文例如red)

title:日历视图标题

5.事件

单击事件 bind:click ="calendarViewDetailShow"

calendarViewDetailShow(e){
  console.log(e.detail)
}

单击2021-03-29的日期,e.detail返回的数据如下,相比传过去的参数,返回的字段多了

isSelect:是否是选中日期

day:日期

{
    "date": "2021-03-29",
    "isSelect": true,
    "day": 29,
    "bottom": "2小时",
    "top": "1节课",
    "list": [{
        "creator": "1331255738911162368",
        "createTime": "2021-03-29 18:54:16",
        "updateTime": "2021-03-29 18:54:27",
        "deleted": false,
        "courseRecordId": "1376487868398043136",
        "studentId": "1330535521876705280",
        "courseDuration": 2,
        "startTime": "2021-03-29 18:30:00",
        "endTime": "2021-03-29 20:30:00",
        "remark": "比例三"
    }]
}

相关文章

  • 微信小程序日历组件开发案例

    今天我们一起写一个微信小程序日历组件 微信小程序日历组件https://github.com/749264345/...

  • 【微信小程序】日历视图组件

    组件介绍 日历展示功能 日期点击功能 git地址 https://gitee.com/gnliscream/cal...

  • 微信小程序日历组件开发

    # 微信小程序日历组件开发 微信小程序基础知识 微信小程序 框架介绍 组件文档 上述是开发小程序的基本知识。 今天...

  • 微信小程序基础

    微信小程序介绍微信小程序开发工具的使用微信小程序框架文件微信小程序逻辑层微信小程序视图层微信小程序组件介绍微信小程...

  • 应用程序UI编程

    基础组件 基础内容组件 表单组件 微信小程序伸缩布局 视图容器 view scroll-viewswiper-view

  • 微信小程序公告滚动通知

    微信小程序实现上下滚动消息提醒,主要是利用swiper组件来实现,swiper组件在小程序中是滑块视图容器。 通过...

  • 微信小程序 日历组件

    思路分析首先最主要的一点,就是要计算出某年某月有多少天,其中涉及到大小月,闰、平年二月。其次,弄清楚每月一号对应的...

  • 全栈开发工程师微信小程序-中(下)

    全栈开发工程师微信小程序-中(下) 微信小程序视图层 wxml用于描述页面的结构,wxss用于描述页面的样式,组件...

  • 小程序组件汇总

    一、什么是微信小程序组件: 组件是视图层的基本组成单元。作为产品经理掌握小程序提供的组件是功能/页面设计的基础。 ...

  • 近期200+热门微信小程序demo源码下载汇总

    微信小程序 外卖demo 微信小程序demo:课程列表 微信小程序demo:宅男社区 微信小程序——日历(支持农历...

网友评论

    本文标题:【微信小程序】日历视图组件

    本文链接:https://www.haomeiwen.com/subject/vnefrltx.html