项目中使用了json文件作为配置存储
_loadJson(file, data) {
let url = cc.url.raw("resources/cfg/" + file + ".json");
cc.loader.load(url,
function (curCount, totalCount, itemObj) {
},
function (err, results) {
this._index++;
if (err) {
console.log("解析配置文件" + file + "失败: " + JSON.stringify(err));
} else {
if (results) {
// 在2.0中,返回的数据对象有变化
data['data'] = results.json || results;
console.log("---------------------------");
console.log(JSON.stringify(results.json));
console.log("---------------------------");
this._onProgress(file);
if (this._index >= this._totalIndex) {// 加载完成
this._onComplete();
}
} else {
this._onError(file);
}
}
}.bind(this));
},
加载json使用了cc.loader.load接口,在开发预览过程中没有任何问题,当发布web版本后就出现上边的错误,根据错误提示,我发现发布的web-mobile本地竟然真的没有提示的文件,也就是说json好像真的没有参与构建,这。。。。。。bug
Cocos Creator v2.0.1
Cocos Creator v2.0.1-beta.2
都出现了该问题

