pc宽度缩放环境判断
import Store from '@/store'
const setBodyClass = (...cls) => {
document.body.classList.remove(...['ipad', 'h5', 'pc', 'small-pc', 'big-pc', 'not-h5'])
document.body.classList.add(...cls)
}
function setIsMobile () {
const screenWidth = document.documentElement.clientWidth
if ((screenWidth < 1280 && screenWidth >= 768)) {
Store.commit('SET_SCREEN_STATUS', 'ipad')
setBodyClass('ipad', 'not-h5')
} else if (screenWidth < 768) {
/**
* width小于775判定为移动端,参考币安
*/
Store.commit('SET_SCREEN_STATUS', 'h5')
setBodyClass('h5')
} else if (screenWidth < 1540) {
Store.commit('SET_SCREEN_STATUS', 'smallPc')
setBodyClass('pc', 'small-pc', 'not-h5')
} else {
Store.commit('SET_SCREEN_STATUS', 'bigPc')
setBodyClass('pc', 'big-pc', 'not-h5')
}
}
setIsMobile()
window.addEventListener('resize', setIsMobile)

浙公网安备 33010602011771号