【发布时间】:2018-11-16 20:04:16
【问题描述】:
我正在编写一个 JavaScript 以使用 Google Chrome 将文件写入 aframe 虚拟现实应用程序中的本地目录。
在调试时我得到了这个错误:
Uncaught TypeError: Failed to construct 'File': 2 arguments required, but `only 1 present.`
我从其他人那里得到了以下代码,但我不明白为什么谷歌浏览器说这需要 2 个参数?
<script>
/// write to file
var txtFile = "skycolour.txt";
var file = new File(txtFile);
var str = "My string of text";
file.open("w"); // open file with write access
file.writeln("First line of text");
file.writeln("Second line of text " + str);
file.write(str);
file.close();
</script>
感谢您的帮助。
【问题讨论】:
-
var file = new File([""], txtFile);
标签: javascript html google-chrome