将 file:///C:/ 转换为可用的格式可以使用以下方法:

  1. 使用 decodeURI() 函数进行解码:
var url = "file:///C:/";
var decodedUrl = decodeURI(url);
console.log(decodedUrl);

输出结果为:file:///C:/

  1. 使用 replace() 函数删除 file:// 前缀:
var url = "file:///C:/";
var formattedUrl = url.replace("file://", "");
console.log(formattedUrl);

输出结果为:C:/

注意:这里只是将 file:// 前缀删除了,如果需要将路径中的斜杠进行转义或其他处理,可以根据具体需求进行修改。

js 将 fileC 转成可用的格式

原文地址: https://www.cveoy.top/t/topic/ihAn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录