0

我正在开发 android 应用程序,我需要访问 FileSystem。当我运行该页面时,我收到错误“无法读取未定义的属性'名称'”。这是我的页面代码

<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <!--<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />-->
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.3.2.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/fullcalendar.css" />
    <link rel="stylesheet" type="text/css" href="css/fullcalendar.print.css" />
    <script src="js/jquery.js"></script>
    <script src="js/jquery.mobile-1.3.2.min.js"></script>
    <script src="js/fullcalendar.js"></script>
    <script src="js/gcal.js"></script>
    <script src="js/phonegap-1.4.1.js"></script>
    <script type="text/javascript" src="phonegap.js"></script>
    <script type="text/javascript" charset="utf-8" src="cordova-3.0.0.js"></script>
    <script type="text/javascript" charset="utf-8">

        document.addEventListener("deviceready", onDeviceReady);
        function onDeviceReady() {
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess(), fail);
        }

        function onFileSystemSuccess(fileSystem) {
            alert('test');
            try {
                var fs = fileSystem.name;
                alert(String(fs));
                var directoryEntry = fileSystem.root;
                alert(directoryEntry.fullPath);
                console.log(fileSystem.root.name);
            } catch(err) {
                alert(err.message);
            }
        }

        function test() {
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess(), fail);
        }

        function fail(evt) {
            console.log(fail.target.error.code);
            alert(evt.target.error.code);
        }

    </script>
</head>
<body>
    <div id="header" data-role="header" >
        <a hrefeader="#" data-icon="back" data-rel="back" title="Go back">Back</a>
    </div>
    <div id="content" data-role="content">
        <a data-role="button" rel="external" onclick="test()" >Test Local Storage</a>
    </div>
</body>

我的 phonegap 版本是 3.0.0-0.14.3 谁能帮助我或告诉我做错了什么?

4

1 回答 1

1

您不能将括号传递给它,requestFileSystem因为它需要一个带参数的函数。改用这个:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
                                                                       // ^^
于 2013-10-14T11:51:47.447 回答