JS代码中加入以下代码
let ua = navigator.userAgent.toLowerCase();
let isWeixin = ua.indexOf('micromessenger') != -1;
if (!isWeixin) {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=888"
}
如果是Vue项目则写在index.html中
<!DOCTYPE html>
<html>
<head>
<%= require('html-loader!@/layout/head.html') %>
<title>大家乐智力运动大赛</title>
</head>
<body>
<div id="app"></div>
</body>
<script>
// //禁止在外置浏览器打开
let ua = navigator.userAgent.toLowerCase();
let isWeixin = ua.indexOf('micromessenger') != -1;
if (!isWeixin) {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=888"
}
</script>
</html>