This file contains 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
// 屏幕可视窗口大小 | |
window.innerHeight // 标准浏览器及IE9+ | |
document.documentElement.clientHeight // 标准浏览器及低版本IE标准模式 | |
document.body.clientHeight // 低版本混杂模式 | |
// 浏览器窗口顶部与文档顶部之间的距离,也就是滚动条滚动的距离 | |
window.pagYOffset // 标准浏览器及IE9+ | |
document.documentElement.scrollTop // 兼容ie低版本的标准模式 | |
document.body.scrollTop // 兼容混杂模式 |
This file contains 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
export function b64toBlob(data, contentType = '', sliceSize = 512) { | |
const byteCharacters = atob(data) | |
const byteArrays = [] | |
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { | |
const slice = byteCharacters.slice(offset, offset + sliceSize) | |
const byteNumbers = new Array(slice.length) | |
for (let i = 0; i < slice.length; i++) { | |
byteNumbers[i] = slice.charCodeAt(i) | |
} | |
const byteArray = new Uint8Array(byteNumbers) |
This file contains 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
[ | |
{ | |
"name": { | |
"en": { | |
"official": "Republic of Albania", | |
"common": "Albania" | |
}, | |
"zh": { | |
"official": "阿尔巴尼亚共和国", | |
"common": "阿尔巴尼亚" |
This file contains 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
[ | |
{ | |
"name": { | |
"en": { | |
"official": "Republic of Albania", | |
"common": "Albania" | |
}, | |
"zh": { | |
"official": "阿尔巴尼亚共和国", | |
"common": "阿尔巴尼亚" |
This file contains 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 titleCase(str) { | |
str = str.toLowerCase() | |
return str.charAt(0).toUpperCase() + str.slice(1) | |
} |
This file contains 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
<link rel="icon" type="image/png" href="./src/favicon.png"> |
This file contains 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
export function numberWithCommas(num) { | |
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') | |
} |
This file contains 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 parseTime(time, format = 'y-m-d h:i:s') { | |
if (!time) { | |
return '0000-00-00 00:00:00' | |
} | |
const date = time instanceof Date ? time : new Date(parseInt(time, 10)) | |
const formatObj = { | |
y: date.getFullYear(), | |
m: date.getMonth() + 1, |
NewerOlder