h5 处理方法:
var element = (el instanceof HTMLElement) ? el : (document.querySelector(el) || document.querySelector(’#’ + el));
if (element.tagName === "CANVAS") {width = element.width;height = element.height;//it is already a canvas, we wrap it around with a divthis.canvas = localCanvas = element;if (CC_EDITOR) {this.container = localContainer = document.createElement("DIV");if (localCanvas.parentNode)localCanvas.parentNode.insertBefore(localContainer, localCanvas);}else {// Can not move the existing canvas's position in iOS 14, so use canvas.parentNode as containerthis.container = localContainer = localCanvas.parentNode;}} else {//we must make a new canvas and place into this elementif (element.tagName !== "DIV") {cc.warnID(3819);}width = element.clientWidth;height = element.clientHeight;this.canvas = localCanvas = document.createElement("CANVAS");this.container = localContainer = document.createElement("DIV");element.appendChild(localContainer);localCanvas.setAttribute('id', 'GameCanvas');}localContainer.setAttribute('id', 'Cocos2dGameContainer');localCanvas.parentNode !== localContainer && localContainer.appendChild(localCanvas);this.frame = (localContainer.parentNode === document.body) ? document.documentElement : localContainer.parentNode;function addClass (element, name) {var hasClass = (' ' + element.className + ' ').indexOf(' ' + name + ' ') > -1;if (!hasClass) {if (element.className) {element.className += " ";}element.className += name;}}addClass(localCanvas, "gameCanvas");localCanvas.setAttribute("width", width || 480);localCanvas.setAttribute("height", height || 320);localCanvas.setAttribute("tabindex", 99);
添加 div
重新构建 cocos creator
nodejs version 12以下
gulp version 3 以下
windows power shell 管理员 运行
set-ExecutionPolicy RemoteSigned A
gulp build-dev --max-old-space-size=8192
如果觉得《ios14升级后 出现黑屏问题》对你有帮助,请点赞、收藏,并留下你的观点哦!