校验数据类型
export const typeOf = function (obj) { return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); };
开启全屏
export const launchFullscreen = (element) => { if (element.requestFullscreen) { element.requestFullscreen(); } else if (element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if (element.msRequestFullscreen) { element.msRequestFullscreen(); } else if (element.webkitRequestFullscreen) { element.webkitRequestFullScreen(); } };
关闭全屏
export const exitFullscreen = () => { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } };
大小写转换
export const turnCase = (str, type) => { switch (type) { case 1: return str.toUpperCase(); case 2: return str.toLowerCase(); case 3: //return str[0].toUpperCase() + str.substr(1).toLowerCase() // substr 已不推荐使用 return str[0].toUpperCase() + str.substring(1).toLowerCase(); default: return str; } };
标签:助力,return,JS,高效,element,else,export,str,document From: https://www.cnblogs.com/luoyihao/p/16769119.html