当前位置:网站首页>uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
2022-06-10 15:23:00 【苦修的木鱼】
获取当前日期时间戳
/** * 获取当前时间戳 */
function time() {
return Math.round(new Date() / 1000);
}
字符串转时间戳
/** * 字符串转时间戳 * @example: time:2022-01-12 12:00:00 */
function stringTotime(time) {
let time_sub= time.substring(0, 19);
time_sub= time_sub.replace(/-/g, "/");
return Math.round(new Date(time_sub).getTime() / 1000);
}
富文本解析图片添加前缀或后缀(常用与处理oss图片处理)
// 详情
richTxt = richTxt.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (match, p1) => {
return `<img src='${
this.imgUrl()+p1 + '/okh710auto'}' style="max-width:100%"/>`;
});
- 利用
.replace()(方法用于在字符串中用一些字符替换另一些字符,或替换一个与正则表达式匹配的子串。) - 参看文档 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/replace

边栏推荐
- 2022 the 14th Nanjing International artificial intelligence product exhibition
- Several reasons and solutions of virtual machine Ping failure
- Mitm (man in the middle attack)
- 反“内卷”,消息称 360 企业安全云将上线“一键强制下班”功能,电脑自动关闭办公软件
- 自推荐-深入理解RUST标准库内核
- Software intelligence: formal rules of AAAS system metrics and grammars
- Golang uses reflection to directly copy data from one structure to another (through the same fields)
- Kubernetes 1.24: preventing unauthorized volume mode switching
- 凸函数的Hessian矩阵与高斯牛顿下降法增量矩阵半正定性的理解
- 华为云SRE确定性运维介绍
猜你喜欢

How to improve document management

【高代码文件格式API】上海道宁为您提供文件格式API集——Aspose,只需几行代码即可创建转换和操作100多种文件格式

How to build a customer-centric product blueprint: suggestions from the chief technology officer

4. Meet panuon again UI. Title bar of silver form

RSA a little bit of thought

4、再遇Panuon.UI.Silver之窗体标题栏

This article introduces you to j.u.c's futuretask, fork/join framework and BlockingQueue

数字化管理中台+低代码,JNPF开启企业数字化转型的新引擎

反“内卷”,消息称 360 企业安全云将上线“一键强制下班”功能,电脑自动关闭办公软件

企业如何提升文档管理水平
随机推荐
Hutool使用总结(VIP典藏版)
视觉SLAM常见的QR分解SVD分解等矩阵分解方式求解满秩和亏秩最小二乘问题(最全的方法分析总结)
面试题详情
Vins Theory and Code detail 4 - Initialization
docket命令
Interview question details
AutoRunner自动化测试工具如何创建项目-Alltesting|泽众云测试
Software intelligence: formal rules of AAAS system metrics and grammars
云图说|每个成功的业务系统都离不开APIG的保驾护航
opencv神经网络库之SVM和ANN_MLP的使用
2022 the 14th Nanjing International artificial intelligence product exhibition
Quelqu'un a même dit que ArrayList était deux fois plus grand. Aujourd'hui, je vais vous montrer le code source ArrayList.
Kubernetes 1.24: preventing unauthorized volume mode switching
竟然还有人说ArrayList是2倍扩容,今天带你手撕ArrayList源码
信息论与编码2 期末复习-BCH码
Yuntu says that every successful business system cannot be separated from apig
terminator如何设置字体显示不同颜色
C# 游戏雏形 人物地图双重移动
Tensorflow actual combat Google deep learning framework version 2 learning summary tensorflow installation
Kubernetes 1.24:statefulset introduces maxunavailable copies