css
% vh calc
不使用rem,因为工程化html的font-size是会影响全局,如果改为较容易计算的100px,全部都得改,框架的内容也得改,较为麻烦
ps:em是根据父级元素的font-size来计算
局部自适应用%和vh来计算,再配合calc减去固定的边距
@media适配不同的屏幕
js
监听屏幕的变化
window.addEventListener('resize', this.handleLayouts)
window.removeEventListener('resize', this.handleLayouts)
判断设备navigator.userAgent
export function isMobile() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobi/i.test(navigator.userAgent)
}