- translate3d引发样式模糊,如果元素的宽高是奇数,当用百分比时计算出来的结果是有小数点的,但是浏览器最小的像素是1像素,所以会引发模糊,体现在chrome上
2.微信小程序 canvasToTempFilePath: fail canvas is empty报错
首先 wx.createCanvasContext("canvas", this)要传入this上下文
wx.canvasToTempFilePath({
canvasId: 'picture-canvas',
success: function (res) {
var tempFilePath = res.tempFilePath;
console.log(tempFilePath);
_this.isShow = false;
_this.$emit("createImg", tempFilePath)
},
fail: function (res) {
console.log(res);
}
},this)
也要传入this
wx.createSelectorQuery().select('.search-content').boundingClientRect(rect=>{
console.log(rect.height)
}).exec();
rect一直为null
解决:
const query = wx.createSelectorQuery().in(this)
query.select('#canvas-bg').boundingClientRect()
query.exec(function (rect) {
w1 = parseInt(rect[0].width / 2);
h1 = parseInt(rect[0].height / 2);
That.drawRegion(itemsArc, ctx);//每一份扇形的内部绘制。
})
加个in(this),添加上下文
4. canvas转换为图片在安卓机上图片背景为黑色
setTimeout(()=>{
wx.canvasToTempFilePath()
},300)
加个300ms的延迟,或者可以更大
5. 苹果机上 new Date(date).getTime()会出现NaN
new Date(date.replace(/-/g,'/')).getTime()
而且出来的结果还需要除以`1000``