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});
本文共 250 字,大约阅读时间需要 1 分钟。
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});
转载于:https://www.cnblogs.com/cynthia-wuqian/p/7388787.html