Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Chrome.filesystem时出错:Chrome.filesystem未查找_Javascript_Google Chrome_Google Chrome Devtools_Google Chrome App - Fatal编程技术网

Javascript 使用Chrome.filesystem时出错:Chrome.filesystem未查找

Javascript 使用Chrome.filesystem时出错:Chrome.filesystem未查找,javascript,google-chrome,google-chrome-devtools,google-chrome-app,Javascript,Google Chrome,Google Chrome Devtools,Google Chrome App,我正在尝试制作一个chrome应用程序,它可以访问本地文件系统并监视特定目录,以检查是否有新文件出现,所以我需要使用chrome.filesystem,根据谷歌提供的代码,它给我的错误是chrome.filesystem未定义 代码: chooseDirButton.addEventListener('click', function(e) { chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(

我正在尝试制作一个chrome应用程序,它可以访问本地文件系统并监视特定目录,以检查是否有新文件出现,所以我需要使用chrome.filesystem,根据谷歌提供的代码,它给我的错误是chrome.filesystem未定义

代码:

  chooseDirButton.addEventListener('click', function(e) {
          chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(theEntry) {
            if (!theEntry) {
              output.textContent = 'No Directory selected.';
              return;
            }
            // use local storage to retain access to this file
            chrome.storage.local.set({'chosenFile': chrome.fileSystem.retainEntry(theEntry)});
            loadDirEntry(theEntry);
          });
        });
Menifest文件:

{
  "manifest_version": 2,
  "name": "Test",
  "short_name": "Test",
   "minimum_chrome_version": "31",
  "description": "Description for Test",

  "version": "0.0.1.0",

  "icons": {
    "16": "assets/icon_16.png",
    "128": "assets/icon_128.png"
  },

  "app": {
    "background": {
      "scripts": ["background.js"],
      "persistent": false
    }
  },
"permissions": [
    {"fileSystem": ["write", "retainEntries", "directory"]},
    "storage","notifications","webview","http://*/*","fileSystem"
  ],
  "file_handlers": {
    "text": {
      "types": [
          "text/*"
      ]
    }
  }
}
background.js:

chrome.app.runtime.onLaunched.addListener(function(launchData) {
  chrome.app.window.create('index.html', {id:"fileWin", innerBounds: {width: 800, height: 500}}, function(win) {
    win.contentWindow.launchData = launchData;
  });
});
如何使用chrome.filesystem?请帮忙。多谢各位


编辑问题以包括您的清单文件请看一看我也添加了menifest文件。清单似乎没问题。。这段代码在哪里,你是如何用这段代码打开页面的?你可以在这里检查这段代码:我知道这段代码来自谷歌的一个例子,但是调试这类东西的方法是删除无关的东西,直到你把问题降到最低限度。扔掉所有关于通知、窗口属性以及与chrome.fileSystem.chooseEntry无关的东西。如果这样做有效,开始添加其他材料,直到其断裂。你淹没在不必要的复杂性中!(我使用的原则是:1.chrome.fileSystem.chooseEntry的定义众所周知。2.你的应用程序不工作。3.因此答案必须介于两者之间。)