搭建Http服务器
$ npm i -g http-server
$ http-server ./
TypeError: Laya.Templet is not a constructor
laya.core.js:17243 TypeError: Laya.Templet is not a constructor
错误原因:项目少了一个laya.ani.js
类库导致,进入编辑模式,按快捷键F9进入项目设置,选择类库设置,将laya.ani.js
勾选即可。
解决方案
Uncaught getUint16 error - Out of bounds
laya.core.js:18126 Uncaught getUint16 error - Out of bounds
错误原因:龙骨动画太长还是无用数据太多
Laya.loader.getRes() undefined
错误原因:Laya.loader.getRes()
获取的资源必须先预加载
//资源预加载
const res = [
{url : "image/start/bg-loading.jpg", type : Laya.Loader.IMAGE},
{url : "image/start/beat.png", type : Laya.Loader.IMAGE},
{url : "image/start/progress_preload.png", type : Laya.Loader.IMAGE},
{url : "image/start/progress_preload$bar.png", type : Laya.Loader.IMAGE},
{url : "skeleton/loadsk.png", type : Laya.Loader.IMAGE},
{url : "skeleton/loadsk.sk", type : Laya.Loader.BUFFER},
{url : "image/start/txt-notice.png", type : Laya.Loader.IMAGE},
{url : "sound/bgm.mp3", type : Laya.Loader.SOUND}
];
Laya.loader.load(res, Laya.Handler.create(this, this.init));
laya.debugtool.js
var Browser=laya.utils.Browser;//
laya.debugtool.js:5 Uncaught ReferenceError: laya is not defined
Uncaught Can not find class laya.html.dom.HTMLDivElement
laya.core.js:20878 Uncaught Can not find class laya.html.dom.HTMLDivElement
image.png
编辑模式下使用【F9】项目设置中类库设置,选中laya.html.js
后确认引入类库。接着使用【F8】编译项目,编译成功后查看/bin/index.js
文件中是否已经添加了laya.html.js
。
经过上述操作后,laya.html.dom.HTMLDivElement
错误仍然存在。
TypeScript 实现日志
export default class Log{
constructor(){}
public static trace(...args:any[]){
console.log.apply(console, args);
}
}