FileReader readyState property provides the current state of the reading operation a FileReader is in. A FileReader exists in one of the following states:

状态 描述
0 EMPTY Reader has been created. None of the read methods called yet.
1 LOADING A read method has been called.
2 DONE The operation is complete.
EMPTY
FileReader has been created, but no readAs method was called yet.
LOADING
A readAs method was invoked. A File or Blob is being read, and no error has occurred yet.
DONE
The read operation is complete. This could mean that: the entire File or Blob has been read into memory, a file read error occurred, or abort() was called and the read was cancelled.

范例

var reader = new FileReader();
console.log('EMPTY', reader.readyState); // readyState will be 0
reader.readAsText(blob);
console.log('LOADING', reader.readyState); // readyState will be 1
reader.onloadend = function () {
  console.log('DONE', reader.readyState); // readyState will be 2
};
					

A number which is one of the three possible state constants define for the FileReader API。

规范

规范 状态 注释
文件 API
The definition of 'readyState' in that specification.
工作草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
readyState Chrome 7 Edge 12 Firefox 3.6 IE 10 Opera 11 Safari 6 WebView Android Yes Chrome Android Yes Firefox Android 32 Opera Android 11 Safari iOS 6.1 Samsung Internet Android Yes

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: