当前位置:网站首页>uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
2022-06-21 12:01: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

边栏推荐
- How does Huawei build a project centered project management system from 0 to 1?
- Adapter power supply automatic test equipment | introduction to charger ATE test system nsat-8000
- 第k小__
- 巨头局终战:即时零售
- Ansible operating instructions for configuring SSH authentication free for the first time
- Knowledge points: several special wiring methods for PCB
- Compilation de l'environnement vs Code + GCC développé par stm32
- Customization of power aging test system | overview of charging pile automatic test system nsat-8000
- 6-Zabbix监控自动发现第三方中间件内存及CPU使用情况
- Nanjing University static program analyses -- intermediate representation learning notes
猜你喜欢

【云原生 | Devops篇】Jenkins安装与实战(二)

Knowledge points: several special wiring methods for PCB

Nanjing University static program analyses -- Introduction learning notes

STM32笔记之 SWJ(JTAG-DP和 SW-DP)

2022 HV electrician judgment questions and answers
![SSD [target detection]](/img/f5/1a4a9868cddb24fb08db9fae4db290.png)
SSD [target detection]

矩形覆盖面积

WPF 使用 MAUI 的自绘制逻辑

Customization of power aging test system | overview of charging pile automatic test system nsat-8000

CPU、MPU、MCU、SoC、MCM介绍
随机推荐
knowing和understanding的区别
华为云发布桌面IDE-CodeArts
Knowledge points: several special wiring methods for PCB
Compilation de l'environnement vs Code + GCC développé par stm32
浅论OCA\UV-OCA LOCA\SLOCA 四种全贴合工艺
100w的数据表比1000w的数据表查询更快吗?
Interesting research on mouse pointer interaction
ThinkPHP security development specification
是德示波器軟件,Keysight示波器上比特機軟件NS-Scope
20n10-asemi medium and low voltage MOS tube 20n10
i.MX - RT1052 SPI和 I2C接口
STM32笔记之 PWM(脉宽调制)
The k-th small__
XML实体注入漏洞
重磅,MapStruct 1.5 发布,这次终于支持Map转为Bean了!
External attention tensorflow (under update)
tensorflow中使用的一些函数
动手学数据分析 数据可视化
MySQL 5.6.49 enterprise version setting password complexity policy
SDCC编译器 + VSCode开发 8位微控制器