[LayaAir 2.0]如何让发布后的H5加载资源用src或href指向本地路径,而不是网络请求

最近做一个需求,希望加载的资源直接放在用户手机,app直接打包,离线也能使用的形式,但看源码发现加载资源是用下面这种ajax的形式加载的,但是这种加载方式,会不支持本地路径的file协议。如何处理
 
laya.core.js:18284 Access to XMLHttpRequest at 'file:///E:/Game-SuperMary/SuperMary/release/web/res/atlas/option.atlas' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
 
load(url) {
            var me = this;
            url = URL.formatURL(url);
            this.url = url;
            this.audioBuffer = WebAudioSound._dataCache[url];
            if (this.audioBuffer) {
                this._loaded(this.audioBuffer);
                return;
            }
            WebAudioSound.e.on("loaded:" + url, this, this._loaded);
            WebAudioSound.e.on("err:" + url, this, this._err);
            if (WebAudioSound.__loadingSound[url]) {
                return;
            }
            WebAudioSound.__loadingSound[url] = true;
            var request = new XMLHttpRequest();
            console.log('url', url)
            request.open("GET", url, true);
            request.responseType = "arraybuffer";
            request.onload = function () {
                if (me._disposed) {
                    me._removeLoadEvents();
                    return;
                }
                me.data = request.response;
                WebAudioSound.buffs.push({ "buffer": me.data, "url": me.url });
                WebAudioSound.decode();
            };
            request.onerror = function (e) {
                me._err();
            };
            request.send();
        }
已邀请:

要回复问题请先

商务合作
商务合作