写入文件的代码时这样的
-
保存数据到本地
-
@param {*} textToWrite 要保存的文件内容
-
@param {*} fileNameToSaveAs 要保存的文件名
-
@memberof FileMgr
*/
saveForBrowser(textToWrite, fileNameToSaveAs) {
if (cc.sys.isBrowser) { console.log("浏览器"); let textFileAsBlob = new Blob([textToWrite], { type: 'application/json' }); let downloadLink = document.createElement("a"); downloadLink.download = fileNameToSaveAs; downloadLink.innerHTML = "Download File"; if (window.webkitURL != null) { // Chrome allows the link to be clicked // without actually adding it to the DOM. downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob); } else { // Firefox requires the link to be added to the DOM // before it can be clicked. downloadLink.href = window.URL.createObjectURL(textFileAsBlob); // downloadLink.onclick = destroyClickedElement; downloadLink.style.display = "none"; document.body.appendChild(downloadLink); } downloadLink.click(); }}
但是这个方法不能指定文件的储存路径 并且每次都是生成的一个新文件
请教一下各位大佬 能不能指定修改某个路径下的文件 把数据储存进去