搭建Http服務(wù)器
$ 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
錯(cuò)誤原因:項(xiàng)目少了一個(gè)laya.ani.js類庫(kù)導(dǎo)致,進(jìn)入編輯模式,按快捷鍵F9進(jìn)入項(xiàng)目設(shè)置,選擇類庫(kù)設(shè)置,將laya.ani.js勾選即可。

解決方案
Uncaught getUint16 error - Out of bounds
laya.core.js:18126 Uncaught getUint16 error - Out of bounds
錯(cuò)誤原因:龍骨動(dòng)畫太長(zhǎng)還是無(wú)用數(shù)據(jù)太多
Laya.loader.getRes() undefined
錯(cuò)誤原因:Laya.loader.getRes() 獲取的資源必須先預(yù)加載
//資源預(yù)加載
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】項(xiàng)目設(shè)置中類庫(kù)設(shè)置,選中laya.html.js后確認(rèn)引入類庫(kù)。接著使用【F8】編譯項(xiàng)目,編譯成功后查看/bin/index.js文件中是否已經(jīng)添加了laya.html.js。
經(jīng)過(guò)上述操作后,laya.html.dom.HTMLDivElement錯(cuò)誤仍然存在。
TypeScript 實(shí)現(xiàn)日志
export default class Log{
constructor(){}
public static trace(...args:any[]){
console.log.apply(console, args);
}
}