测试代码
export default class TestView extends TestViewUI {
constructor() {
super();
}
onAwake() {
this.nativeImg = new Image();
let style = this.nativeImg.style;
style.position = 'absolute';
style.visibility = 'hidden';
style.zIndex = 9999;
style.height = screen.height + 'px';
style.width = Math.floor(screen.height / Laya.stage.height * Laya.stage.width) + 'px';
document.body.appendChild(this.nativeImg)
}
onEnable() {
Laya.timer.once(1000, this, this.delayShowImg);
}
delayShowImg() {
let canvas = this.drawToCanvas(Laya.stage.width, Laya.stage.height, 0, 0);
let str = canvas.toBase64('image/jpeg', 0.9);
this.nativeImg.src = str;
this.nativeImg.style.visibility = 'visible';
}
}