分解tool.js
This commit is contained in:
parent
fa056e547c
commit
48880c2f67
|
|
@ -1,6 +1,14 @@
|
||||||
const tool = {
|
/*
|
||||||
|
* @Descripttion: 工具集
|
||||||
|
* @version: 1.0
|
||||||
|
* @LastEditors: sakuya
|
||||||
|
* @LastEditTime: 2021年6月28日19:13:13
|
||||||
|
*/
|
||||||
|
|
||||||
|
const tool = {}
|
||||||
|
|
||||||
/* localStorage */
|
/* localStorage */
|
||||||
data: {
|
tool.data = {
|
||||||
set(table, settings) {
|
set(table, settings) {
|
||||||
var _set = JSON.stringify(settings)
|
var _set = JSON.stringify(settings)
|
||||||
return localStorage.setItem(table, _set);
|
return localStorage.setItem(table, _set);
|
||||||
|
|
@ -20,9 +28,10 @@ const tool = {
|
||||||
clear() {
|
clear() {
|
||||||
return localStorage.clear();
|
return localStorage.clear();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
/* Fullscreen */
|
/* Fullscreen */
|
||||||
screen(element){
|
tool.screen = function (element) {
|
||||||
var isFull = !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
|
var isFull = !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
|
||||||
if(isFull){
|
if(isFull){
|
||||||
if(document.exitFullscreen) {
|
if(document.exitFullscreen) {
|
||||||
|
|
@ -45,13 +54,15 @@ const tool = {
|
||||||
element.webkitRequestFullscreen();
|
element.webkitRequestFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
/* 复制对象 */
|
/* 复制对象 */
|
||||||
objCopy(obj){
|
tool.objCopy = function (obj) {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
},
|
}
|
||||||
|
|
||||||
/* 日期格式化 */
|
/* 日期格式化 */
|
||||||
dateFormat(date, fmt='yyyy-MM-dd'){
|
tool.dateFormat = function (date, fmt='yyyy-MM-dd') {
|
||||||
date = new Date(date)
|
date = new Date(date)
|
||||||
var o = {
|
var o = {
|
||||||
"M+" : date.getMonth()+1, //月份
|
"M+" : date.getMonth()+1, //月份
|
||||||
|
|
@ -71,9 +82,10 @@ const tool = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt;
|
return fmt;
|
||||||
},
|
}
|
||||||
|
|
||||||
/* 千分符 */
|
/* 千分符 */
|
||||||
groupSeparator(num){
|
tool.groupSeparator = function (num) {
|
||||||
num = num + '';
|
num = num + '';
|
||||||
if(!num.includes('.')){
|
if(!num.includes('.')){
|
||||||
num += '.'
|
num += '.'
|
||||||
|
|
@ -82,6 +94,5 @@ const tool = {
|
||||||
return $1 + ',';
|
return $1 + ',';
|
||||||
}).replace(/\.$/, '');
|
}).replace(/\.$/, '');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default tool
|
export default tool
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue