
获得徽章 0
- 判断浏览器
项目引入了摩洛哥编辑器,不支持ie,我在ie或低版本浏览器中提示用户使用谷歌浏览器访问~
-----------------割(怀念当初的糗事百科了~
)-----
var browserSpec = (function(){
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return {name:'IE',version:(tem[1] || '')};
}
if(M[1]=== 'Chrome'){
tem = ua.match(/\b(OPR|Edg)\/(\d+)/);
if(tem != null) return {name:tem[1].replace('OPR', 'Opera'),version:tem[2]};
}
M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem = ua.match(/version\/(\d+)/i))!= null)
M.splice(1, 1, tem[1]);
return {name:M[0], version:M[1]};
})();
console.log('browserSpec:', browserSpec);展开评论点赞 - 前端读文件
const onChangeFile = (event) => {
var selectedFile = event.target.files[0];//获取读取的File对象
console.log(selectedFile)
let { type } = selectedFile;
if (type !== 'application/json') {
message.error('不支持此文件格式!');
return;
}
var reader = new FileReader();//这里是核心!!!读取操作就是由它完成的。
reader.readAsText(selectedFile);//读取文件的内容
reader.onload = function () {
console.log(JSON.parse(this.result))
toHandleJson(JSON.parse(this.result));
};
}
摘抄别的的git,mark一下展开评论点赞 - // 数组去重
const hash = {};
const newArray = data.reduce((item, next)=>{
hash[next.name] ? '' : hash[next.name] = true && item.push(next);
return item;
},[])展开赞过31