-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
刮刮卡组件上设置width和height只能使用pax单位,但是在手机端宽高用px是不是不太友好,我看scratch组件的index.js中didMount函数中计算rpx的方法,计算设备宽度用了screenWidth,应该使用windowWidth,我目前是把scratch组件复制到本地的components中,使用本地组件,是可以使用rpx作为单位的。
my.getSystemInfo({
success: res => {
// 根据rpx 宽高比计算出实际 px 宽高比
const pr = res.windowWidth / 750
this.setData({
pr,
})
this.ctx = my.createCanvasContext('scratch-canvas')
this.draw(); // 刮刮卡容器初始化
this.area = pr * this.props.width * pr * this.props.height // canvas �面积
this.clearPercent = 0; // 被清除像素的所有选区占 canvas 面积的百分比
}
})
Metadata
Metadata
Assignees
Labels
No labels