当前位置:网站首页>数据格式化小组件
数据格式化小组件
2022-07-21 17:42:00 【阿弥陀佛@么么哒】
**
/* 合法uri */
**
export function validateURL(textval) {
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return urlregex.test(textval)
}
/**
* 获取文件相对于浏览器的地址
- @param {[type]} file [文件流]
- @return {[url]} [相对于浏览器的安全加密地址]
*/
export const getblobUrl = (file) => {
let url = ''
if (window.createObjcectURL !== undefined) {
url = window.createOjcectURL(file)
} else if (window.URL !== undefined) {
url = window.URL.createObjectURL(file)
} else if (window.webkitURL !== undefined) {
url = window.webkitURL.createObjectURL(file)
}
return url
}
/**
* 格式化时间
- @param {[type]} time [description]
- @return {[type]} [description]
*/
export const formatDateTimeList = time => {
time = new Date(time)
let _hour = time.getHours()
let _minute = time.getMinutes()
let _second = time.getSeconds()
let _year = time.getFullYear()
let _month = time.getMonth()
let _date = time.getDate()
if (_hour < 10) {
_hour = '0' + _hour
}
if (_minute < 10) {
_minute = '0' + _minute
}
if (_second < 10) {
_second = '0' + _second
}
_month = _month + 1
if (_month < 10) {
_month = '0' + _month
}
if (_date < 10) {
_date = '0' + _date
}
return (
_year +
'-' +
_month +
'-' +
_date
// +
// ' ' +
// _hour +
// ':' +
// _minute +
// ':' +
// _second
)
}
/**
* 截取时间
- @param {[type]} time [description]
- @return {[type]} [description]
*/
export const getViewTime = time => {
if(time){
return time.split(' ')[0]
}
return ''
}
*Android
function isAndroid() {
return /(?:android)/.test(window.navigator.userAgent.toLowerCase());
}
*移动端
function isWap() {
return !!window.navigator.userAgent
.toLowerCase()
.match(
/(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)/i
);
}
*app
function isApp() {
return !!window.navigator.userAgent
.toLowerCase()
.match(
/(csdn)/i
);
}
*拼接url
//拼接url
function setParamsList(params, isFirst = true) {
var paramsData = "";
for (var Key in params) {
if (typeof params[Key] != "function") {
paramsData += Key + "=" + (params[Key]||"") + "&";
}
}
paramsData = paramsData.substr(0, paramsData.length - 1);
return `${
isFirst ? "?" : "&"}${
paramsData}`;
}
边栏推荐
- “万物互联,使能千行百业”,2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛即将开幕
- 三星6818LED驱动的编写
- Guan Zhengxiong: implement QA generation algorithm based on pre training model and intelligent operation and maintenance
- MMDrawerController 获取当前VC进行Push和Pop
- 2.4. 特殊概要文件的属性
- 给OES纹理添加雪花特效
- solo 文章 推送到社区端失败
- 一道数据库查询面试题
- 履约系统退餐流程方案设计
- My ideal "meta universe"
猜你喜欢
Cannot read property ‘type‘ of undefined Occurred while linting **\index. jsx:1
移除iPhone手机删不掉的绿色logo的百宝箱App
MMDrawerController第一次加载侧边栏高度问题
C textbox password box setting
【干货】知识共享的障碍及解决方法
NodeJS使用Express框架进行POST请求报“BadRequestError:request aborted”
ArrayList源码解析
OSPF routing control
使用OpenGL纹理数组实现高精度实时Lut滤镜
Openlayers uses canvas to draw round avatar icons
随机推荐
RK3288关于LVDS信号配置和1080p视频信号的详解
A method of keeping the original scale of OpenGL map
Scheme design of meal return process of performance system
C textbox password box setting
管道,重定向以及正则表达式
grep,egrep,fgrep字符匹配
[dry goods] obstacles and solutions to knowledge sharing
Hisilicon [hi3531]gpio lighting application and register operation
Custom picture crop box
单细胞论文记录(part18)--Spectral clustering based on learning similarity matrix
命令行编辑的快捷键,以及操作技巧命令
OpenGL画坐标轴指示图
海思Hi3531||瑞芯微RK1109用rtsp服务器实现h264推流
leetcode_两数相加_个人解法
浙大《概率与数理统计》第四版证明随机变量X,Y的相关系数的绝对值小于1,及一些疑问
RT-Thread中常用的指令
Es version i9-13900k appeared, CPU-Z database score data is too modest
Is the computing power of human brain really weak
履约系统退餐流程方案设计
单细胞论文记录(part17)--Integrating sc transcriptomic data across different conditions, tech and species