diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/idbenvironment | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/idbenvironment')
-rw-r--r-- | files/zh-cn/web/api/idbenvironment/index.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/idbenvironment/index.html b/files/zh-cn/web/api/idbenvironment/index.html new file mode 100644 index 0000000000..6eff07e146 --- /dev/null +++ b/files/zh-cn/web/api/idbenvironment/index.html @@ -0,0 +1,71 @@ +--- +title: IDBEnvironment +slug: Web/API/IDBEnvironment +translation_of: Web/API/IDBEnvironment +--- +<p>{{APIRef()}}</p> + +<div class="warning"> +<p><strong>注意! </strong>: 对于 Firefox 52, the property defined in this mixin has been moved to the {{domxref("WindowOrWorkerGlobalScope")}} mixin, and other browsers will follow suit. Look to that page for up-to-date <a href="/zh-CN/docs/IndexedDB">details. IndexedDB API</a></p> +</div> + +<p><a href="/zh-CN/docs/IndexedDB"> IndexedDB API</a>提供的帮助类<strong><code>IDBEnvironment</code></strong><code><font face="Arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">包含了一个</span></font>indexedDB</code> 属性, 这个属性可以比较方便的操作IndexedDB. 它是由{{domxref("window")}} 和{{domxref("Worker")}} 实现的最顶级 IndexedDB接口.</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{domxref("IDBEnvironment.indexedDB")}} {{readonlyInline}}</dt> + <dd>该属性为应用程序提供了异步访问索引数据库(IndexedDB)的构件. 它包含一个 {{domxref("IDBFactory")}} 对象</dd> +</dl> + +<h2 id="示例">示例</h2> + +<p>下述代码演示了如何创建一个异步打开数据库的请求, 当该请求的<code>onsuccess</code> 回调被执行时, 该数据库被打开.</p> + +<pre class="brush: js;highlight:[3]">var db; +function openDB() { + var DBOpenRequest = window.indexedDB.open("toDoList"); + DBOpenRequest.onsuccess = function(e) { + db = DBOpenRequest.result; + }; +} +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">说明</th> + </tr> + <tr> + <td>{{SpecName('IndexedDB', '#idl-def-IDBEnvironment', 'IDBEnvironment')}}</td> + <td>{{Spec2('IndexedDB')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> + +<div> +<div class="hidden">此处的兼容性表格由结构性的数据自动生成. 如果你想参与贡献这类数据, 请在以下链接提交PR <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> </div> + +<p>{{Compat("api.IDBEnvironment")}}</p> +</div> + +<h2 id="参考">参考</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB">如何使用IndexedDB</a></li> + <li>打开事务: {{domxref("IDBDatabase")}}</li> + <li>使用事务: {{domxref("IDBTransaction")}}</li> + <li>为键值设置范围: {{domxref("IDBKeyRange")}}</li> + <li>获取或修改数据库的数据: {{domxref("IDBObjectStore")}}</li> + <li>使用游标: {{domxref("IDBCursor")}}</li> + <li>参考示例: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li> +</ul> |