如何使用FileSystem API的window.requestFileSystem? [英] How to use window.requestFileSystem of FileSystem API?
本文介绍了如何使用FileSystem API的window.requestFileSystem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在javascript中编写了以下代码:
I have written below code in javascript:
javascript代码:
javascript code:
var fs=null;
function initFS() {
window.requestFileSystem =window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem (window.TEMPORARY, 1024 * 1024, function (filesystem) {
fs = filesystem;
}, errorHandler);
}
html代码:
<input type="button" id="button2" name="click" value="show" onclick="initFS();" />
但在 initFS函数
中单击显示按钮后,在 window.requestFileSystem行(window.TEMPORARY,1024 * 1024,函数(文件系统){
它显示错误为未捕获的类型错误".我的代码有什么错误吗?
but after clicking on show button in initFS function
, after line window.requestFileSystem (window.TEMPORARY, 1024 * 1024, function (filesystem) {
it is showing error as "uncaught type error". Is there any mistake in my code?
推荐答案
您无法定义errorHandler
You can not define errorHandler
var fs=null;
function initFS() {
window.requestFileSystem =window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function (filesystem) {
fs = filesystem;
console.log(fs);
}, errorHandler);
}
function errorHandler(e) {
console.log(e); // it show everything that you want
}
这篇关于如何使用FileSystem API的window.requestFileSystem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文