window.navigator.userAgent //检测当前运行浏览器的设备是什么
通过navigator.userAgent.indexOf('iPhone')来获取不同的客户端版本,例如‘iPhone’,然后使用 window.resize()=function(){} 返回不同样式给客户端.
window.onresize = () => {
Xys()
}
function Xys() {
var userAgent = navigator.userAgent
var html = document.querySelector('html')
html.className = ''
if (userAgent.indexOf('iPhone') != -1) {
html.classList.add('iPhone')
} else if (userAgent.indexOf('Android') != -1) {
html.classList.add('Android')
} else if (userAgent.indexOf("iPad") != -1) {
html.classList.add('iPad')
} else {
html.classList.add('pc')
}
}