原代碼canvas
var WINDOW_WIDTH = window.outerWidth; var WINDOW_HEIGHT = window.outerHeight; var canvas1,canvas2,canvas3,context1,context2,context3; var num = 200; var stars = []; var mouseX = WINDOW_WIDTH/2; var mouseY = WINDOW_HEIGHT/2; var rnd; var contentArr = []
緣由: var WINDOW_WIDTH = window.outerWidth;這個須要換成固定的數字iphone
咱們找到緣由了,是iphone8動態設置canvas的寬高的時候有問題,若是不在一開始設置canvas的寬高,後面setDate進去的沒有效果。咱們給了canvas設置了寬高的默認值就解決了。可是其餘手機沒有這個問題。 以下:code
var WINDOW_WIDTH = 1000; var WINDOW_HEIGHT = 1000; var canvas1,canvas2,canvas3,context1,context2,context3; var num = 200; var stars = []; var mouseX = WINDOW_WIDTH/2; var mouseY = WINDOW_HEIGHT/2; var rnd; var contentArr = []