也就是说你可能会遇到pc端网页 和 手机端 两个平台独立开发 当屏幕缩小时跳转手机端网页 那么下面的代码就能帮你解决这个问题
<script>
window.onload = function () {
// window.onload 进入页面之后就会判断屏幕大小跳转链接
function fun1() {
const getWindowInfo = () => {
const windowInfo = {
width: window.innerWidth,
hight: window.innerHeight
}
// console.log(windowInfo);
if (windowInfo.width <= 1200) {
window.location.href = 'xxx/xxxx.xx'
}
};
window.addEventListener('resize', getWindowInfo);
};
fun1();
function f2() {
var lw = window.innerWidth;
if (lw <= 1200) {
window.location.href = 'xxx/xxxx.xx'
} else {
}
}
f2()
};
</script>