This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const date = moment() | |
const firstDayOfYear = moment(date.format('YYYY-01-01')) | |
// 获得第多少周(跨年周算第一周) | |
const weeks = ( | |
// 获得第多少天 | |
date.diff(firstDayOfYear, 'days') - | |
// 减去第一周天数 | |
(7 - firstDayOfYear.weekday()) - | |
// 减去该时间当前周的天数 | |
date.weekday() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 垂直水平居中 | |
* 可增加 flex-direction: column; 让div保持块级元素 | |
*/ | |
div { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img { | |
filter: brightness(0) invert(1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function animate () { | |
if (TWEEN.update()) { | |
requestAnimationFrame(animate) | |
} | |
} | |
new TWEEN.Tween(this.tweenedColor) | |
.to(this.color, 750) | |
.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript (FILE_URL, async = true, type = 'text/javascript') { | |
return new Promise((resolve, reject) => { | |
try { | |
const scriptEle = document.createElement('script') | |
scriptEle.type = type | |
scriptEle.async = async | |
scriptEle.src = FILE_URL | |
scriptEle.addEventListener('load', (ev) => { | |
resolve() |