700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Unity WebGL打包微端时遇到的indexedDB加载问题

Unity WebGL打包微端时遇到的indexedDB加载问题

时间:2019-04-19 06:10:14

相关推荐

Unity WebGL打包微端时遇到的indexedDB加载问题

同一个链接,在浏览器和其他人的微端里都没问题,我本地的微端执行连最开始的unity主程序加载都无法执行。

在UnityLoader.js里一点一点地加输出,查了好久才找到解决办法(只是还没明白原因),问题出在indexedDB的使用方法中:

try {var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;var openRequest = indexedDB.open(databaseName);openRequest.onupgradeneeded = function (e) {initDatabase(e.target.result); //加上这句就好了var objectStore = e.target.result.createObjectStore(store, { keyPath: "url" });["version", "company", "product", "updated", "revalidated", "accessed"].forEach(function (index) { objectStore.createIndex(index, index); });};openRequest.onsuccess = function (e) { initDatabase(e.target.result); };openRequest.onerror = function (e) { initDatabase(null); };setTimeout(openRequest.onerror, 1000);} catch (e) {initDatabase(null);}

原本的代码会在openRequest.onupgradeneeded里执行e.target.result.createObjectStore时导致触发openRequest.onerror,抛出一个AbortError,但凭输出也查不到更具体的信息了,也没有找到具体的原因,暂时就先这样了吧。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。