实用小技巧

141 阅读1分钟
  • vscode 删除所有console.log()
搜索替换
正则1: (console.log\()(.*)(\))

正则2: console.log(\S\s?.*)
为空
  • url字符串结尾补充/
/**
* 给字符串末尾自动加‘/’,即如果字符串不以‘/’结尾则添加‘/’
* @param {string} path 
* @return {string} path + '/' | path
*/
 function autoAppendSlash(path) { 
      return /\/$/.test(path) ? path : path +'/';
  }