postcss-edrpx2rem
v1.0.1
Published
2倍(750px)设计稿32rpx==浏览器1rem==16px
Downloads
1
Readme
cnpm i -D postcss postcss-edrpx2rem
适用范围设计单位 rpx 转换为 rem 1rpx=0.5px 设计稿 750px 手机端 375px
修改文件 nuxt.config.js build: { postcss: [ //require('postcss-px2rem')({ remUnit: 50 }), require('postcss-edrpx2rem')({}), ],
npm login npm publish
!function() {
var w = window.screen.width,
r = (w === 2560 ? 1 : w / 375) * 16 + 'px';
document.documentElement.style.fontSize = r;
console.log('浏览器宽度' + w + 'px', '单位1rem=' + r)
var data = {},
add = function(src, num, type) {
data[src] = num === undefined ? "加载" : num;
var obj = document.createElement(type === 'js' ? "script" : "link");
type === 'js' ? obj.src = src : obj.rel = 'stylesheet', obj.href = src;
document.head.appendChild(obj);
},
fn = function(e) {
e = window.event || e;
var o = e.target || e.srcElement,
url = o.getAttribute("src") || o.getAttribute("href") || '',
type = o.nodeName === "SCRIPT" ? 'js' : (o.nodeName === "LINK" ? 'css' : '');
if (url && type) {
if (url in data) {
data[url] = "失败";
} else setTimeout(function() {
add(url, "再次", type)
}, 500);
}
};
document.addEventListener("error", fn, true);
}();