1234567891011121314151617181920 |
- module.exports.px2rpx = function(data){
- let changeValue = function(props){
- // rate 比例,px转rpx 1:2
- let rate = 2
- Object.keys(props).forEach(item=>{
- if(props[item].constructor === Number){
- props[item] = props[item] * rate
- }
- if(props[item].constructor === Object){
- changeValue(props[item])
- }
- })
- }
- // data传进来是一个数组
- data.forEach(sector=>{
- changeValue(sector.style)
- })
- return data
- }
|