- 当前 Bug 的表现(可附上截图)
- 预期表现
canvas.style.width = canvas.width(未横屏之前的宽)
canvas.style.height = canvas.height(未横屏之前的高)
- 复现路径
- 提供一个最简复现 Demo
测试环境ios微信小游戏
以下为game.js代码片段
let sysInfo = wx.getSystemInfoSync();
let canvas = window.canvas;
let orgWidth = canvas.width;
let orgHeight = canvas.height;
console.log(“org canvas:”, canvas);
canvas.style[“transformOrigin”] = “0% 0% 0px”;
canvas.width = sysInfo.pixelRatio * orgHeight;//宽高翻转
canvas.height = sysInfo.pixelRatio * orgWidth;//宽高翻转
canvas.style.bottom = “0”;
canvas.style.right = “0”;
canvas.style.top = “0px”;
canvas.style.left = “0px”;
canvas.style[“transform”] = “matrix(” + (1 / sysInfo.pixelRatio) + ", 0, 0, " + (1 / sysInfo.pixelRatio) + “, 0, 0)”;
console.log(“update canvas:”, canvas);
这里打印出来canvas.style的width,height一直都是0,我想知道是什么原因?,参见下图
//egret.wxgame.WebPlayer中也是这样设置,最后看到canvas.style 宽高有值(原canvas的宽高)
你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。