当前位置:网站首页>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

边栏推荐
- 数字化管理中台+低代码,JNPF开启企业数字化转型的新引擎
- 云图说|每个成功的业务系统都离不开APIG的保驾护航
- Ada Logics:CRI-O整体安全审计项目
- ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解0——整体框架与理论基础知识
- 如何构建以客户为中心的产品蓝图:来自首席技术官的建议
- VINS理论与代码详解4——初始化
- rk3399_9.0去掉设置的一级菜单network & internet
- 4. Meet panuon again UI. Title bar of silver form
- How to write a global notice component?
- 一款完整的多用户微信公众平台开发源码,带文档免费分享
猜你喜欢

2022南京国际智慧工地装备展览会

CVPR 2022 oral | SCI: fast, flexible and robust low light image enhancement
![[high code file format API] Shanghai daoning provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code](/img/43/086da4950da4c6423d5fc46e46b24f.png)
[high code file format API] Shanghai daoning provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code

详解OpenCV的函数filter2D(),并提醒大家它做的运算并不是卷积运算而是相关运算

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

Vins Theory and Code detail 4 - Initialization

3、再遇HandyControl之窗体

云图说|每个成功的业务系统都离不开APIG的保驾护航

RSA a little bit of thought

RSA a little bit of thought
随机推荐
CentOS Linux is dead! Oracle Linux may be a better alternative
虚拟机ping不通的几种原因及解决办法
Net core Tianma XingKong series - Interface Implementation for dependency injection and mutual conversion of database tables and C entity classes
ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解0——整体框架与理论基础知识
Problems with database creation triggers
ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 0 - overall framework and theoretical basic knowledge
Comment construire un plan de produit axé sur le client: conseils du CTO
QT interface nested movement based on qscrollarea
3. Encounter the form of handycontrol again
VINS理论与代码详解4——初始化
[high code file format API] Shanghai daoning provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code
小程序警告:Now you can provide attr `wx:key` for a `wx:for` to improve performance.
Day10/11 recursion / backtracking
微信小程序 颜色渐变
cmake实战记录(一)
Mitm (man in the middle attack)
Tensorflow actual combat Google deep learning framework version 2 learning summary tensorflow installation
Kubernetes 1.24: preventing unauthorized volume mode switching
云图说|每个成功的业务系统都离不开APIG的保驾护航
After class assignment for module 8 of phase 6 of the construction practice camp