当前位置:网站首页>uniapp中常用到的方法(部分) - 時間戳問題及富文本解析圖片問題
uniapp中常用到的方法(部分) - 時間戳問題及富文本解析圖片問題
2022-06-10 15:30: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

边栏推荐
- ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解2——IMU初始化
- 初学pytorch踩坑
- Wechat applet slides to the top
- Kubernetes 1.24: 防止未经授权的卷模式转换
- Google Earth engine (GEE) - real time global 10 meter land use / land cover (LULC) data set based on S2 images
- 100003字,带你解密 双11、618电商大促场景下的系统架构体系
- VINS理論與代碼詳解4——初始化
- Day10/11 递归 / 回溯
- HKU and NVIDIA | factuality enhanced language models for open ended text generation
- Kubernetes 1.24:StatefulSet引进了maxUnavailable副本数
猜你喜欢

如何构建以客户为中心的产品蓝图:来自首席技术官的建议

Common QR decomposition, SVD decomposition and other matrix decomposition methods of visual slam to solve full rank and deficient rank least squares problems (analysis and summary of the most complete

数据库创建触发器的问题

AutoCAD - set text spacing and line spacing

opencv神经网络库之SVM和ANN_MLP的使用

opencv#4 手写体识别:自建训练集完美

Explain the opencv function filter2d() in detail and remind you that the operation it does is not convolution but correlation operation
Cap version 6.1 Release Notice
CAP 6.1 版本发布通告

Super practical operation! Calibration and registration of Kinect depth map and RGB camera for hands-on teaching
随机推荐
This article introduces you to j.u.c's futuretask, fork/join framework and BlockingQueue
Day10/11 递归 / 回溯
共创地市价值空间,2022年华为商业分销地市百城行·宁波站成功举办
初识RPC
Kubernetes 1.24: 避免为 Services 分配 IP 地址时发生冲突
【Rust日报】2022-04-19 Rust异步框架的性能评估
自媒体视频热门思路分享
Software intelligence: formal rules of AAAS system metrics and grammars
Explain the opencv function filter2d() in detail and remind you that the operation it does is not convolution but correlation operation
How to open an account for agricultural futures? Are there any financial conditions?
Get to know RPC
Wechat applet slides to the top
如何写一个全局的 Notice 组件?
Technology sharing | quick intercom, global intercom
ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解1——IMU流型预积分
Detailed explanation of binary search
How to write a global notice component?
Vins theory and code explanation 0 -- theoretical basis in vernacular
从“初代播种”到“落地生花”,广和通在5G商用三年间做了什么?
HKU and NVIDIA | factuality enhanced language models for open ended text generation