通用的代码总结
//在电脑浏览变成手机端,自适应手机端网站
var w = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
if (768>w){
window.location.href="http://m.1jianmedia.com" + window.location.href.replace(window.location.origin, "");
}
//利用JS来判断页面是在手机端还是在PC端打开的方法
window.location.href = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? "https://www.baidu.com/" : "http://news.baidu.com/";
//字符串为空返回true
isEmpty(obj) {
if (obj === null || obj === undefined || (typeof obj === "string" && obj.toLowerCase() === "null") || obj === "" || obj === 0 || obj.length === 0) {
return true;
} else {
return false;
}
},
判断浏览器还是微信分享
$("#shareId").click(function(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){//微信浏览器
$(".sharemodel").show();
}else{
$(".model").show();
}
});
判断是安卓手机还是ios
changeIphone(){
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
if (isAndroid) {
return true
}else{
return false
}
},
//“全选”的全选事件
allChecked(){
let self = this;
if(this.$(".del_box input:checkbox").length === this.$(".del_box input:checked").length) {
this.$('.del_box input').each(function(i,v){
self.$(v).prop("checked", false);
});
this.$('.changebox input').prop("checked", false);
} else {
this.$('.del_box input').each(function(i,v){
self.$(v).prop("checked", true);
});
this.$('.changebox input').prop("checked", true);
}
},
S
// this.$nextTick(()=>{
// //设置默认选中项
// this.$(document).on('click','.accountTypeli',(e)=>{
// this.$(e.currentTarget).toggleClass('clicks');
// // if(this.$(e.currentTarget)[0].className.indexOf('clicks') == -1){
// // this.$(e.currentTarget).addClass("clicks");
// // }else{
// // this.$(e.currentTarget).removeClass("clicks");
// // }
// })
// })
//滚动条
<div class="public-number">
<ul class="public">
<li class="click">
<img class="definition" src="../../image/accountmsg/wechat.png" alt="">
<p>微信公众号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/mzl.png" alt="">
<p>新浪微博</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/toutiao.png" alt="">
<p>今日头条</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/baijia.png" alt="">
<p>百家号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/qie.png" alt="">
<p>企鹅媒体平台</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/tout.png" alt="">
<p>东方头条</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/fish.png" alt="">
<p>大鱼号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/onenumber.png" alt="">
<p>一点资讯</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/sfox.png" alt="">
<p>搜狐新闻</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/wangyi.png" alt="">
<p>网易新闻</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/xinlang.png" alt="">
<p>新浪看点</p>
</li>
<li class="click">
<img class="definition" src="../../image/accountmsg/bjtime.png" alt="">
<p>北京时间</p>
</li>
<li class="click">
<img class="definition" src="../../image/accountmsg/fengh.png" alt="">
<p>凤凰号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/wechat.png" alt="">
<p>微信公众号</p>
</li>
<li class="click">
<img class="definition" src="../../image/accountmsg/mzl.png" alt="">
<p>新浪微博</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/toutiao.png" alt="">
<p>今日头条</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/baijia.png" alt="">
<p>百家号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/qie.png" alt="">
<p>企鹅媒体平台</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/tout.png" alt="">
<p>东方头条</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/fish.png" alt="">
<p>大鱼号</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/onenumber.png" alt="">
<p>一点资讯</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/sfox.png" alt="">
<p>搜狐新闻</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/wangyi.png" alt="">
<p>网易新闻</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/xinlang.png" alt="">
<p>新浪看点</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/bjtime.png" alt="">
<p>北京时间</p>
</li>
<li>
<img class="definition" src="../../image/accountmsg/fengh.png" alt="">
<p>凤凰号</p>
</li>
</ul>
</div>
.public-number{
background-color: #F2F2F2;
padding: .13rem .16rem .08rem;
box-sizing: border-box;
.public{
height: 1.72rem;
overflow-y:scroll;
display: flex;
flex-wrap: wrap;
&::-webkit-scrollbar{
width: 4px;
background-color: #FFFFFF;
border-radius: 2px;
}
&::-webkit-scrollbar-thumb{
background-color: #969696;
border-radius: 2px;
}
&::-ms-scrollbar{
width: 4px;
background-color: #FFFFFF;
border-radius: 2px;
}
&::-webkit-scrollbar-thumb{
background-color: #969696;
border-radius: 2px;
}
&::-o-scrollbar{
width: 4px;
background-color: #FFFFFF;
border-radius: 2px;
}
&::-o-scrollbar-thumb{
background-color: #969696;
border-radius: 2px;
}
&::-moz-scrollbar{
width: 4px;
background-color: #FFFFFF;
border-radius: 2px;
}
&::-moz-scrollbar-thumb{
background-color: #969696;
border-radius: 2px;
}
li{
width: 74px;
height: auto;
text-align: center;
position: relative;
margin-top: .12rem;
padding: 3px 1px;
border: 1px solid #F2F2F2;
cursor: pointer;
.definition{
width:.46rem;
height: .46rem;
}
p{
font-size: .12rem;
color: #7A7F82;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.show{
width: .2rem;
height: .2rem;
position: absolute;
right: 8px;
top: -5px;
z-index: 999;
display: none;
}
&:hover{
.show{
display: block;
}
}
}
.click{
background: #fff;
border: 1px solid #CFCFCF;
border-radius: 3px;
}
}
}