- canvas图像在模拟器中加载正常,真机测试下拉刷新出现问题,是什么问题?
模拟器初次打开和下拉刷新都正常: [图片] 真机测试初次打开正常下拉刷新异常: [图片] raw2D: function(highData, lowData){ wx.createSelectorQuery().select('#myCanvas').fields({node: true, size: true}).exec((res)=>{ var canvas = res[0].node const systemInfo = wx.getSystemInfoSync() const screenWidth = systemInfo.screenWidth const screenHeight = systemInfo.screenHeight const dpr = systemInfo.pixelRatio const ctx = canvas.getContext('2d') ctx.clearRect(0, 0, canvas.width, canvas.height) // 清空canvas const xOffset = screenWidth / 10 // x轴的偏移量 const groupSpacing = screenWidth / 5 // 5等分屏幕宽度 var sh = screenHeight * 0.4 * 0.6 // canvas的宽度 canvas.width = screenWidth * dpr canvas.height = screenHeight * dpr * 0.4 * 0.6 ctx.scale(dpr, dpr) // 获取每日最高温度的最大值和每日最低温度的最小值 var maxHighTemp = this.maxNum(highData); var minLowTemp = this.minNum(lowData); // 获取5日温度的最大差值(canvas图片的网格数) var grid = maxHighTemp-minLowTemp; // 每一canvas网格的像素大小 const distance = Math.floor(sh / grid) const new_distance = Math.floor(distance * (grid - 2) / grid) ctx.lineWidth = 2; ctx.font = '16px sans-serif'; // highData开始 ctx.beginPath() ctx.fillStyle = "#CD5555" ctx.strokeStyle = "#CD5555" var htX = 0, htY = 0 const TextOffset = 10 for (let i = 0; i < highData.length; i++) { htX = i * groupSpacing + xOffset htY = (maxHighTemp - highData[i]) * new_distance + distance + new_distance if (i==0){ ctx.moveTo(htX, htY) ctx.fillText(highData[i], htX-TextOffset, htY-TextOffset) }else{ ctx.lineTo(htX, htY) ctx.fillText(highData[i], htX-TextOffset, htY-TextOffset) } } ctx.stroke() // lowData开始 ctx.beginPath() ctx.fillStyle = "black" ctx.strokeStyle = "black" var ltX = 0, ltY = 0 for (let i = 0; i < lowData.length; i++) { ltX = i * groupSpacing + xOffset ltY = (sh - (lowData[i] - minLowTemp) * new_distance) - distance if (i==0){ ctx.moveTo(ltX, ltY) ctx.fillText(lowData[i], ltX-TextOffset, ltY-TextOffset) }else{ ctx.lineTo(ltX, ltY) ctx.fillText(lowData[i], ltX-TextOffset, ltY-TextOffset) } } ctx.stroke() }) },
2020-09-09 - 动态加载图片渲染层网络层500错误?
<image wx:if="{{img}}" src="{{img}}"></image> [图片] 图片保存在云服务器,报本地路径 /pages/index/xxx 错误,但图片可以正常显示
2020-07-31