diff options
author | MDN <actions@users.noreply.github.com> | 2021-07-01 00:37:12 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-07-01 00:37:12 +0000 |
commit | b0a393384aa4021c915e6a650c75ff328a054cb2 (patch) | |
tree | 5f049f0db1c3b87c9d8ea12564cf7bc43b0e8f07 /files/zh-cn/web/api/body/bodyused | |
parent | 3f2eea0abf998516fe98d64da8da53a03d36c3ee (diff) | |
download | translated-content-b0a393384aa4021c915e6a650c75ff328a054cb2.tar.gz translated-content-b0a393384aa4021c915e6a650c75ff328a054cb2.tar.bz2 translated-content-b0a393384aa4021c915e6a650c75ff328a054cb2.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/web/api/body/bodyused')
-rw-r--r-- | files/zh-cn/web/api/body/bodyused/index.html | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/files/zh-cn/web/api/body/bodyused/index.html b/files/zh-cn/web/api/body/bodyused/index.html deleted file mode 100644 index fd776b8a65..0000000000 --- a/files/zh-cn/web/api/body/bodyused/index.html +++ /dev/null @@ -1,134 +0,0 @@ ---- -title: Body.bodyUsed -slug: Web/API/Body/bodyUsed -translation_of: Web/API/Body/bodyUsed ---- -<p>{{APIRef("Fetch")}}{{ SeeCompatTable }}</p> - -<p><strong><code>bodyUsed</code></strong><code> 是</code>{{domxref("Body")}} mixin中的一个<code>只读属性。用以表示该body是否被使用过。</code></p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">var myBodyUsed = response.bodyUsed;</pre> - -<h3 id="可能的值">可能的值</h3> - -<p>{{domxref("Boolean")}}.</p> - -<h2 id="示例">示例</h2> - -<p>在以下<a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-request">fetch 请求示例</a>(运行 <a href="http://mdn.github.io/fetch-examples/fetch-request/">fetch request live</a>)。通过{{domxref("Request.Request")}}构造器创建了一个fetch请求,来获得一张JPG图片。当fetch成功后,通过{{domxref("Blob")}} 来使用了fetch返回的资源--{{domxref("URL.createObjectURL")}}创建该资源的URL,并作为 {{htmlelement("img")}}元素的src源来显示图片。</p> - -<p>注意:<code>在response.blob()被调用前后,</code>输出<code>response.bodyUsed的差异。</code></p> - -<h3 id="HTML_Content">HTML Content</h3> - -<pre class="brush: html"><img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png"> -</pre> - -<h3 id="JS_Content">JS Content</h3> - -<pre class="brush: js">var myImage = document.querySelector('.my-image'); -fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/Delete_key1.jpg').then(function(response) { - console.log(response.bodyUsed); - var res = response.blob(); - console.log(response.bodyUsed); - return res; -}).then(function(response) { - var objectURL = URL.createObjectURL(response); - myImage.src = objectURL; -});</pre> - -<p>{{ EmbedLiveSample('Example', '100%', '250px') }}</p> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('Fetch','#dom-body-bodyused','bodyUsed')}}</td> - <td>{{Spec2('Fetch')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{ CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatChrome(42) }} [1]<br> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatGeckoDesktop(39)}} [2]</td> - <td>{{ CompatNo }}</td> - <td> - <p>29 [3]</p> - </td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo }}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Behind a preference in version 41.</p> - -<p>[2] Behind a preference starting with version 34.</p> - -<p>[3] Behind a preference in version 28.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> |