首先需要获取css文件的数据内容,然后进行过滤,并过滤掉不需要的字符内容
export function getCssInFile(data) {
var pattern = /url\((\S*?)\)/g
let fileList = data.match(p...
yekong
2年前 (2022-04-10) 1013℃
0喜欢
js 判断字符串是否包含了指定的内容,并封装,方便复用
代码
export function doesItInclude(string, stringBody) {
var str = new RegExp(string);
return str.test(str...
yekong
2年前 (2022-04-10) 983℃
0喜欢
在用nodejs仿写单页模板扒手的时候,需要处理下载的css文件内的背景图片和字体文件,在处理前,需要先匹配到对应的文件,这里用正则进行文件匹配。
匹配代码
var pattern = /url\((\S*?)\)/g
console.log(res.data.match(pat...
yekong
2年前 (2022-04-08) 997℃
0喜欢
实例
判断字符串是否是以’//‘开头,如果是则追加’http:‘
var u="//www.wanjunshijie.com"
var url = u
if (u.startsWith('//')) {
url = 'h...
yekong
2年前 (2022-04-08) 1239℃
0喜欢
在用nodejs仿写单页模板扒手的时候,需要一个功能,获取文件后缀名,文件后缀名的情况有几种,比如文件名后面会有问号或者会拼接一些参数等情况,这就需要获取文件地址最后一个斜杠后面的内容,然后过滤掉问号以及拼接参数,剩下的应该就是图片名称了。
获取最后一个斜杠后面的内容
var d...
yekong
2年前 (2022-04-05) 1989℃
1喜欢
that.data.remark = that.data.remark.replace(/https:\/\/www.wanjunshijie.com\/file/g, configs.uploadImg)
that.data.remark = that.data.remark....
yekong
2年前 (2022-04-02) 1027℃
0喜欢
金额相加,金额可能是字符串,所以需要先转为数字,再进行相加,金额需要保留两位小数,所以需要对小数做一下处理
(Number(res.data.money) + Number(res.data.frozenMoney)).toFixed(2)
...
yekong
2年前 (2022-04-01) 1246℃
0喜欢
js代码
var num =2.446242342;
num = num.toFixed(2); // 输出结果为 2.45
vue过滤器
filters: {
getnum: function(data) {
var num = data.toFixed(2)...
yekong
2年前 (2022-03-30) 708℃
0喜欢
字符串过滤
title.replace(/^(.).*(.)$/, "$1******$2")
处理前
都是收费到第三方
处理后
都******方
...
yekong
2年前 (2022-03-18) 1191℃
2喜欢
data-wow-delay="0.5s"
<items class="wow bounceInRight" data-wow-delay="0.5s">
<nianchanzhi...
yekong
2年前 (2022-03-13) 913℃
0喜欢