var content = ‘23px‘ content = content.replace(/(\d+)px/g, function(s, t) { s = s.replace(‘px‘, ‘‘); var value = parseInt(s) * 0.001; // 100px = 1rem return value + "rem"; //0.23rem });
时间: 2024-10-05 04:57:55
var content = ‘23px‘ content = content.replace(/(\d+)px/g, function(s, t) { s = s.replace(‘px‘, ‘‘); var value = parseInt(s) * 0.001; // 100px = 1rem return value + "rem"; //0.23rem });