- 小程序安卓白屏
昨晚提交的体验版,在ios上面正常,安卓手机扫码体验版二维码进入就白屏。页面只有头部显示了首页icon和小程序名称,点击首页icon可以进入首页。根据社区里出现白屏的问答,各种方式都用了,app.js内容全注释,只剩下App({}),首页index.js也是全部注释,只剩下Page({}),分包全部注释,检查域名,检查网络,换电脑换开发工具上传等等都尝试了,安卓还是白屏,来来回回就是不进pages/index/index页面,'pages/index/index' has not been registered yet,网上各种方法都尝试了无效,一上午都没有什么进展,最后还是恢复了昨晚版本,间隔了几个小时,下午再次测试,几个安卓手机居然又全部没问题了,希望遇到这种情况的各位大佬分享一下解决的经验。
2021-03-10 - 监听动画事件无效 4个监听3个没效果?
原本写了一个动画效果,希望可以动画可以循环,https://developers.weixin.qq.com/community/develop/doc/000044dff8c5389eba690f7ad56000?highLine=Animation%25E5%25BE%25AA%25E7%258E%25AF 社区帖子,也是同样需求,根据技术推荐,尝试用[代码]bindtransitionend[代码] [代码]bindanimationstart[代码] [代码]bindanimationiteration[代码] [代码]bindanimationend[代码] 来监听动画事件,四个都尝试了,就bindtransitionend有效果,其他三个没有作用。 bindtransitionend="transEnd" bindanimationstart="animationStart" bindanimationiteration="animationStepEnd" bindanimationend="animationEnd" transEnd(){ console.log('trans end') }, animationStart(){ console.log('animation start') }, animationStepEnd(){ console.log('animation step end') }, animationEnd(){ console.log('animation end') } this.animation.opacity(1).step({duration: 1000}) this.animation.right('100rpx').step({duration: 3000}) this.animation.opacity(0).step({duration: 1000}) this.animation.right('-100rpx').step({duration: 0}) [图片] 结果是bindtransitionend 每个step执行一次,其他三个完全不执行,希望官方看一下。 https://developers.weixin.qq.com/community/develop/doc/000680bc448450026116253cc56c00 这个帖子相同问题到现在都没官方回答
2020-08-05 - 安卓手机canvas clearRect 卡顿严重
[图片] 点击按钮,按钮以及按钮后的背景消失,开始绘制canvas [图片] 调用drawImage绘制上面的图片,当用户点击、移动时clearRect,在调试工具和iphone上都还可以,但是在安卓上面卡顿特别严重,而且页面会滚动,导致canvas区域移位,下面底层隐藏的图片直接出来了。安卓、ios手指移动时,清除滞后很明显。 class Scratch { /** * @constructs Scratch构造函数 * @param {Object} pageContext page路由指针 * @param {Object} opts 组件所需参数 * @param {Number} opts.canvasWidth 画布宽带 * @param {Number} opts.canvasHeight 画布高度 * @param {String} opts.imageResource 遮罩层图片 * @param {Number} opts.r 笔触半径 * @param {String} opts.awardTxt 底部抽奖文字奖项 * @param {String} opts.awardTxtColor 底部抽奖文字颜色 * @param {String} opts.awardTxtFontSize 底部抽奖文字大小 * @param {String} opts.maskColor 没有图片遮罩层颜色 * @param {Function} opts.callback 结束回调 */ constructor (pageContext, opts) { this.page = pageContext this.canvasWidth = opts.canvasWidth this.canvasHeight = opts.canvasHeight this.imageResource = opts.imageResource this.maskColor = opts.maskColor // this.canvasId = opts.canvasId this.r = opts.r || 4 this.endCallBack = opts.callback this.lastX = 0 this.lastY = 0 this.minX = '' this.minY = '' this.maxX = '' this.maxY = '' this.isStart = false this.init() this.page.touchStart = this.touchStart.bind(this) this.page.touchMove = this.touchMove.bind(this) this.page.touchEnd = this.touchEnd.bind(this) this.page.imgOnLoad = this.imgOnLoad.bind(this) this.page.setData({ scratch: { 'awardTxt': opts.awardTxt, 'awardTxtColor': opts.awardTxtColor, 'awardTxtFontSize': opts.awardTxtFontSize, 'awardTxtLineHeight': opts.canvasHeight, 'width': opts.canvasWidth, 'height': opts.canvasHeight, 'imageResource': opts.imageResource }, 'isScroll': true }) } init () { const { canvasWidth, canvasHeight, imageResource, maskColor } = this const self = this this.ctx = wx.createCanvasContext('scratch') this.ctx.clearRect(0, 0, canvasWidth, canvasHeight) console.log(canvasWidth+' == '+ canvasHeight) if (imageResource && imageResource != '') { wx.downloadFile({ url: imageResource, success: res => { self.ctx.drawImage(res.tempFilePath, 0, 0, canvasWidth, canvasHeight) self.ctx.draw() } }) } else { self.ctx.setFillStyle(maskColor) self.ctx.fillRect(0, 0, canvasWidth, canvasHeight) self.ctx.draw() } } drawRect (x, y) { const { r, minX, minY, maxX, maxY } = this const x1 = x - r > 0 ? x - r : 0 const y1 = y - r > 0 ? y - r : 0 if ('' != minX) { this.minX = minX > x1 ? x1 : minX this.minY = minY > y1 ? y1 : minY this.maxX = maxX > x1 ? maxX : x1 this.maxY = maxY > y1 ? maxY : y1 } else { this.minX = x1 this.minY = y1 this.maxX = x1 this.maxY = y1 } this.lastX = x1 this.lastY = y1 return [x1, y1, 2 * r] } start () { console.log('start') this.isStart = true this.page.setData({ 'isScroll': false }) } restart () { this.init() this.lastX = 0 this.lastY = 0 this.minX = '' this.minY = '' this.maxX = '' this.maxY = '' this.isStart = true this.page.setData({ 'isScroll': false }) } touchStart (e) { if (!this.isStart) return const pos = this.drawRect(e.touches[0].x, e.touches[0].y) // this.ctx.clearRect(pos[0], pos[1], pos[2], pos[2]) this.clearArcFun(pos[0], pos[1], 10, this.ctx) this.ctx.draw(true) } touchMove (e) { if (!this.isStart) return const pos = this.drawRect(e.touches[0].x, e.touches[0].y) // this.ctx.clearRect(pos[0], pos[1], pos[2], pos[2]) this.clearArcFun(pos[0], pos[1], 20, this.ctx) this.ctx.draw(true) } touchEnd (e) { if (!this.isStart) return // 自动清楚采用点范围值方式判断 const { canvasWidth, canvasHeight, minX, minY, maxX, maxY } = this if (maxX - minX > .6 * canvasWidth && maxY - minY > .6 * canvasHeight) { this.ctx.draw() this.endCallBack && this.endCallBack() this.isStart = false this.page.setData({ 'isScroll': true }) } } reset () { this.init() } clearArcFun(x, y, r, ctx) { var stepClear = 0.1;//这是定义精度 clearArc(x, y, r); function clearArc(x, y, radius) { var calcWidth = radius - stepClear; var calcHeight = Math.sqrt(radius * radius - calcWidth * calcWidth); var posX = x - calcWidth; var posY = y - calcHeight; var widthX = 2 * calcWidth; var heightY = 2 * calcHeight; if (stepClear <= radius) { ctx.clearRect(posX, posY, widthX, heightY); stepClear += 0.1; clearArc(x, y, radius); } } } } 求各位大神提出宝贵的优化方案!
2019-06-04 - scroll-view bindscrolltolower
<scroll-view scroll-y="true" bindscrolltolower="nextPage"> <view class="item wx:for="{{getData}}" wx:key="index">{{item.name}}</view> </scroll-view> 假设scroll-view的高度是800rpx,里面的item每个高度80rpx,有十个item,正好填充了scroll-view,向上滚动时,正好可以触发bindscrolltolower,可以加载下一页数据,但是在第一页数据的情况下,删除其中的几个item,item的总高度不到800rpx,滚动就不能触发bindscrolltolower,这种情况下该怎么处理加载下一页的数据问题
2019-05-30