In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to achieve the Sunday calendar switching effect by vue". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The effect is as follows:
Code:
Weekly calendar
{{currentYear}} month of year {{currentMonth}}
One, two, three, four, five, six, {{day.getDate ()}} {{day.getDate ()}} {{day.getDate ()}} new Vue ({el:'# app' Data: function () {return {/ / value: ", endDate:", dateRange: [], dateNum: 0, / / under currentYear: "", / / year currentMonth: "" / / month currentDay: ", / / date currentWeek:", / / week days: [],}}, mounted () {}, created () {/ / Calendar this.dateList (this.dateNum) above Console.log (this.dateRange); / / Calendar this.initData () below;}, methods: {/ / Calendar above / / get the current time on Monday getMonday (date) {var day = date.getDay (); var deltaDay If (day = = 0) {deltaDay = 6;} else {deltaDay = day-1;} var monday = new Date (date.getTime ()-deltaDay * 24 * 60 * 60 * 1000); monday.setHours (0); monday.setMinutes (0); monday.setSeconds (0) Return monday; / / returns 00:00:00 on Monday of the selected time, getDateNew (time) {console.log (time); let times = new Date (time); let year = times.getFullYear () Let month = times.getMonth () + 1 < 10? "0" + (times.getMonth () * 1 + 1): times.getMonth () * 1 + 1; let day = times.getDate () < 10? "0" + times.getDate () * 1: times.getDate () * 1; return year + "-" + month +-"+ day }, dateList (delta) {/ / convert the time object to a timestamp and several days later into a time object var DateNews = this.getMonday ((new Date (). GetTime () / 1000 + 86400 * 7 * delta) * 1000); let startDate = this.getDateNew (DateNews, delta) This.endDate = this.getDateNew (new Date ((DateNews.getTime () / 1000 + 6 * 86400) * 1000); this.dateRange = [startDate, this.endDate];}, arrow (arrow) {if (arrow = = "left") {this.dateNum--; this.dateList (this.dateNum) } else if (arrow = = "right") {this.dateNum++; this.dateList (this.dateNum) }}, / / the following calendar formatDate (year, month, day) {const y = year let m = month if (m < 10) m = `0 ${m} `let d = day if (d < 10) d = `0 ${d} `return `${y}-${m}-${d}`} InitData (cur) {let date =''if (cur) {date = new Date (cur)} else {date = new Date ()} this.currentDay = date.getDate () / today's date this.currentYear = date. GetFullYear () / / current year this.currentMonth = date.getMonth () + 1 / / current month this.currentWeek = date.getDay () / / 1.. 6 if (this.currentWeek = 0) {this.currentWeek = 7} const str = this.formatDate (this.currentYear) This.currentMonth, this.currentDay) / / Today date year-month-day this.days.length = 0 / / Today is Sunday Put it in the seventh position on the first line, the first six show a week by default here, and if you need to display a month, the second loop is I = 0 I-= 1) {const d = new Date (str) d.setDate (d.getDate ()-I) / / console.log (y: "+ d.getDate () this.days.push (d)} for (let I = 1; I)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.