let str = '';
window.onresize = function(){
if(document.body.clientWidth>= 500){
if(str === ''){
str='hello';
console.log(str);
}else{
return;
}
}
}
js监听浏览器变化的函数,大于500px时,打印console.log('hello'),且只打印一次
最新推荐文章于 2025-05-18 08:35:52 发布