Calculated date difference

function DateDiff(sDate1, sDate2) { //sDate1 and sDate2 are in YYYY-MM-DD format
        var aDate, oDate1, oDate2, iDays;
        aDate = sDate1.split("-");
        oDate1 = new Date(aDate[1] + The '-' + aDate[2] + The '-' + aDate[0]);  // Convert to YYYY-MM-DD format
        aDate = sDate2.split("-");
        oDate2 = new Date(aDate[1] + The '-' + aDate[2] + The '-' + aDate[0]);
        iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24); // Convert the difference in milliseconds to days
        //console.log(iDays);
        return iDays;  // Return the difference of days
    }
Copy the code

Gets the date string of how many days ago

GetDateStr(AddDayCount){ // Calculate the date table
    var dd = new Date(a); dd.setDate(dd.getDate()+AddDayCount);// Get the date after AddDayCount
    var y = dd.getFullYear();
    var m = (dd.getMonth()+1) <10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);// Get the date of the current month
    var d = dd.getDate()<10"0"+dd.getDate():dd.getDate();// Get the current number, if less than 10, add 0
    return y + "-"+m+"-"+d;
}
Copy the code

How to set the style of disabled in wechat small program Button?

/** Must "elevate the application priority of the specified style rule (! Important)." * * /
button[disabled] {
    color: #fff ! important;
    background: #5bc0de ! important;
    border-color: #46b8da ! important;
}
Copy the code

Wechat applet custom swiper indicator style

/* Default pointer style */
.swiper .wx-swiper-dot {
  width: 28rpx;
  height: 6rpx;
  background: #333;
  border-radius: 3rpx;
}
 
/* Select the style of the indicator */
.swiper .wx-swiper-dot.wx-swiper-dot-active {
  width: 28rpx;
  height: 6rpx;
  background: #67C787;
  border-radius: 3rpx;
}
Copy the code

Note: If swiper is placed in a custom component, the style will not work. If swiper is written in the WXML of the page, the style will work

Solve the Android phone RMB symbol ¥only display a horizontal method

Copy “¥” using this character. feasible

Waservicemaincontext. js reported an error, the iPhone will not open properly

If the regular expression contains a zero-width assertion (? < =,?

Wechat applet sets the data of the previous page through the page stack

let familydata = e.target.dataset.any
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; // Previous page
    prevPage.setData({
      people_data:familydata
    })
    wx.navigateBack({
      delta: 1,})Copy the code