diff options
author | MDN <actions@users.noreply.github.com> | 2022-03-03 00:14:36 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2022-03-03 00:14:36 +0000 |
commit | 60e68bc9b4fc796aaea41a8c56ec02ad3b6ee618 (patch) | |
tree | 2ca36213a68164fdd9f790708256ef72f2eb520e /files/zh-cn/conflicting/web/api | |
parent | 25415714270338d7fb3090918348748dd35a7ccd (diff) | |
download | translated-content-60e68bc9b4fc796aaea41a8c56ec02ad3b6ee618.tar.gz translated-content-60e68bc9b4fc796aaea41a8c56ec02ad3b6ee618.tar.bz2 translated-content-60e68bc9b4fc796aaea41a8c56ec02ad3b6ee618.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/conflicting/web/api')
-rw-r--r-- | files/zh-cn/conflicting/web/api/filereader/abort_event/index.html | 13 | ||||
-rw-r--r-- | files/zh-cn/conflicting/web/api/filereader/load_event/index.html | 26 |
2 files changed, 39 insertions, 0 deletions
diff --git a/files/zh-cn/conflicting/web/api/filereader/abort_event/index.html b/files/zh-cn/conflicting/web/api/filereader/abort_event/index.html new file mode 100644 index 0000000000..c899854b36 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/filereader/abort_event/index.html @@ -0,0 +1,13 @@ +--- +title: FileReader.onabort +slug: conflicting/Web/API/FileReader/abort_event +translation_of: Web/API/FileReader/onabort +original_slug: Web/API/FileReader/onabort +--- +<p><strong><code>FileReader.onabort</code></strong> 属性包含在终止事件被触发时执行的事件处理程序,举例,当读取文件的过程中需要中止时。</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: js">reader.onabort = function() { ... };</pre> + +<p> </p> diff --git a/files/zh-cn/conflicting/web/api/filereader/load_event/index.html b/files/zh-cn/conflicting/web/api/filereader/load_event/index.html new file mode 100644 index 0000000000..3d48f35fb0 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/filereader/load_event/index.html @@ -0,0 +1,26 @@ +--- +title: FileReader.onload +slug: conflicting/Web/API/FileReader/load_event +tags: + - 文件 +translation_of: Web/API/FileReader/onload +original_slug: Web/API/FileReader/onload +--- +<p>{{APIRef}}</p> + +<p>当 <strong>FileReader </strong>读取文件的方式为<strong> </strong> <a href="/en-US/docs/Web/API/FileReader/readAsArrayBuffer">readAsArrayBuffer</a>, <a href="/en-US/docs/Web/API/FileReader/readAsBinaryString">readAsBinaryString</a>, <a href="/en-US/docs/Web/API/FileReader/readAsDataURL">readAsDataURL</a> 或者 <a href="/en-US/docs/Web/API/FileReader/readAsText">readAsText</a> 的时候,会触发一个 {{event('load')}} 事件。从而可以使用 <strong><code>FileReader.onload</code></strong> 属性对该事件进行处理。</p> + +<h2 id="范例">范例</h2> + +<pre class="brush:js; line-numbers language-js"><code class="language-js">// 一个文件上传的回调 <input type="file" onchange="onChange(event)"> +function onChange(event) { + var file = event.target.files[0]; + var reader = new FileReader(); + reader.onload = function(event) { + // 文件里的文本会在这里被打印出来 + console.log(event.target.result) + }; + + reader.readAsText(file); +} +</code></pre> |