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
File
or
Blob
is being read, and no error has occurred yet.
DONE
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. |
工作草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
FileReader