一次性删除页面中所有console.log()

本文介绍了如何使用VSCode的正则搜索功能一键清除项目中所有的console.log()日志输出,以及如何删除空白行,提升代码整洁度。通过Ctrl+F开启搜索,启用正则模式,输入特定正则表达式,即可快速定位并替换相关行。此外,还分享了删除空白行的正则方法,帮助开发者优化代码结构。
摘要由CSDN通过智能技术生成

        在我们平日里做项目时,经常为了检查数据或者查看报错会使用console.log(),在控制台打印相应内容。

        而通常写一些比较复杂的接口时会留下大量接口,我相信大多数朋友和我一样,写完以后都是继续写新的内容了,以至于项目交付的时候运气起来没有bug,但控制台打印出大片的内容,着实不美观,接下来就让我给你介绍如何一次性删除所有的console.log()

        通过笔者的尝试,idea,webStorm等工具需要下载插件来完成这样的工具,可能大部分人都觉得这样过于麻烦,所以我使用的方法是使用VSCode中的正则搜素替换来完成。

 

        首先使用VSCode打开要修改的文件,ctrl F 打开搜索框 

        然后点击打开使用正则搜索的开关或者通过alt+r快捷键来打开

        最后在搜索框输入[^]*console.log[^]*,就能够搜索到所有带有console.log 的行了,直接替换为空格或者替换为Replace就可以实现一次性将整个文件中的console.log()删除完成。

        最后的最后,还可以通过相同的方法,搜索^\s*(?=\r?$)\n来实现删除所有的空白行,也可以使用每个工具不同的整理代码的快捷键来完成

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
saveImageToLocal(tempFilePath) { const that = this const folderPath = `${plus.io.convertLocalFileSystemURL('_documents')}/uniapp_save/images/`; console.log('临时文件' + tempFilePath) const fileName = this.fromData.number + '_' + Date.now() + ".jpg"; console.log('fromData数据'+this.fromData) console.log('图片名称' + fileName) console.log('当前任务唯一id' + this.fromData.number) const taskData = JSON.stringify(this.fromData); uni.setStorageSync(this.fromData.number, taskData); //numerb 是任务次数 //将图片保存到指定目录 uni.saveFile({ tempFilePath: tempFilePath, filePath: folderPath + fileName, success(res) { console.log("保存成功:", res); // 将保存的图片路径添加到 imgList 数组 that.imgList.push(res.savedFilePath); // 将OID和对应的文件名存储起来 const fileObj = {}; const postData = { uid: that.uid, rid: that.jifangId, mid: that.id, mtid:that.mtid, maid: that.MaiorId, coordinate: that.coordinate, said: that.obj.aid, //天馈id sbid: that.obj.bid, //归属id spid: that.obj.pid, //电源类型 srid: that.obj.rid //机房类型 } fileObj[that.fromData.number] = fileName; const imageData = { oid: that.fromData.number, //这里将最原始的oid替换成本地任务缓存 id filePath: res.savedFilePath, postData: postData, tempFilePath: tempFilePath, taskData: that.fromData }; that.saveData.push(imageData); console.log('imgList是' + JSON.stringify(that.imgList)) console.log(uni.getStorageInfoSync(that.fromData.number)) } }) },这样保存文件图片之后如果我想一次性删掉怎么弄
06-10
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值