Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the date selection plug-in in WeChat Mini Programs

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the date selection plug-in in WeChat Mini Programs". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the date selection plug-in in WeChat Mini Programs.

Effect picture:

Wxml

"{{cur_year | |"--}} year {{cur_month | | "- -"} month "{{item}} {{item}} Click date selection

Js

/ / index.js// gets the application instance Page ({data: {hasEmptyGrid: false, cur_year:', cur_month:',}, onLoad (options) {this.setNowDate ();}, dateSelectAction: function (e) {var cur_day = e.currentTarget.dataset.idx) This.setData ({todayIndex: cur_day}) console.log (`Click date: ${this.data.cur_year} year ${this.data.cur_month} month ${cur_day + 1} day `);}, setNowDate: function () {const date = new Date (); const cur_year = date.getFullYear (); const cur_month = date.getMonth () + 1; const todayIndex = date.getDate ()-1 Console.log (`date: ${todayIndex} `) const weeks_ch = ['Day', 'one', 'two', 'three', 'four', 'five', 'six']; this.calculateEmptyGrids (cur_year, cur_month); this.calculateDays (cur_year, cur_month) This.setData ({cur_year: cur_year, cur_month: cur_month, weeks_ch, todayIndex,})}, getThisMonthDays (year, month) {return new Date (year, month, 0). GetDate ();}, getFirstDayOfWeek (year, month) {return new Date (Date.UTC (year, month-1, 1). GetDay ();}, calculateEmptyGrids (year, month) {const firstDayOfWeek = this.getFirstDayOfWeek (year, month); let empytGrids = [] If (firstDayOfWeek > 0) {for (let I = 0; I < firstDayOfWeek; iTunes +) {empytGrids.push (I);} this.setData ({hasEmptyGrid: true, empytGrids});} else {this.setData ({hasEmptyGrid: false, empytGrids: []});}}, calculateDays (year, month) {let days = []; const thisMonthDays = this.getThisMonthDays (year, month); for (let I = 1 I 12) {newYear = cur_year + 1; newMonth = 1;} this.calculateDays (newYear, newMonth); this.calculateEmptyGrids (newYear, newMonth); this.setData ({cur_year: newYear, cur_month: newMonth})}}) so far, I believe you have a deeper understanding of "how to use the date selection plug-in in WeChat Mini Programs", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report