是否有任何方法只允许用户使用移动浏览器进入网页?例如,阻止试图使用桌面浏览器访问网页的用户。我使用aws托管我的网页nodejs和vuejs
发布于 2021-03-24 19:46:09
因为你用的是vue
npm i -S vue-mobile-detection
然后
<div v-if="$isMobile()">MOBILE</div>
<div v-else>DESKTOP OR TABLET</div>https://renatello.com/vue-js-detect-mobile/
另一种方式
function _isMobile(){
// if we want a more complete list use this: http://detectmobilebrowsers.com/
// str.test() is more efficent than str.match()
// remember str.test is case sensitive
var isMobile = (/iphone|ipod|android|ie|blackberry|fennec/).test
(navigator.userAgent.toLowerCase());
return isMobile;
}
if(!isMobile()){
//redirect to google or do something else
window.location.href = "http://www.google.com";
}https://stackoverflow.com/questions/66788191
复制相似问题