支付宝小程序问题汇总
支付宝小程序的常见问题及技巧,分享给需要的朋友。
1:px转rpx
公式:itemHeight(被转换的高度) * (750 / windowWidth(系统设备宽度))
// 获取设备系统宽度
export const getSystemInfo = () => {
return new Promise(resolve => {
my.getSystemInfo({
success: (res) => {
resolve(res);
}
})
})
}
const { windowWidth } = await getSystemInfo();
this.setData({
itemHeight: this.pxTorpx(itemHeight,windowWidth)
})
pxTorpx(itemHeight,windowWidth){
return itemHeight * (750 / windowWidth);
}
2:父组件调用子组件的setData方法
父组件
onLoad(){
this.childComponent.setData({})
}
子组件
didMount(){
this.$page.childComponent = this;
}
3:支付宝小程序数字滚动
https://github.com/majiang666/count-up
4:支付宝小程序,自定义头部滚动背景渐变
https://github.com/majiang666/app-header
欢迎关注小程序,感谢您的支持!