在读取文件时,有时候会无法打开文件,自动一个空的text文件,原因可能就是文件中带有特殊字符,在进行url转义的时候,导致编码后无法找到指定文件,最后报错。
在进行url地址的时候,可以使用
encodeURIComponent(path)的方法,对链接进行转义。
const href = `/api/${Id}/file?access_token=${token}&path=${encodeURIComponent(path)}`;
在读取文件时,有时候会无法打开文件,自动一个空的text文件,原因可能就是文件中带有特殊字符,在进行url转义的时候,导致编码后无法找到指定文件,最后报错。
在进行url地址的时候,可以使用
encodeURIComponent(path)的方法,对链接进行转义。
const href = `/api/${Id}/file?access_token=${token}&path=${encodeURIComponent(path)}`;