当前位置:网站首页>Utils/index TS tool function
Utils/index TS tool function
2022-07-05 20:58:00 【The legend of Feng】
Source code
import Vue from 'vue';
export { use } from './use';
export const isServer: boolean = Vue.prototype.$isServer;
//Vue The attributes of the prototype Determine whether it is running on the server
export function noop() {}
export function isDef(value: any): boolean {
// value:any Indicates that the parameter passed in is of any type boolean Indicates that the return value is boolean type
return value !== undefined && value !== null;
// The value passed in cannot be undefined Nor is null
}
// in 15.686s 0.486s
export function isObj(x: any): boolean {
// Judge whether a value is object type
// Incoming parameter yes any Any type i
// The return value is boolean
const type = typeof x;
// typeof Judge data type
// typeof When judging the data type null It's also object therefore type Not for null
// The function is also object
return x !== null && (type === 'object' || type === 'function');
}
export function get(object: any, path: string): any {
const keys = path.split('.');
let result = object;
keys.forEach(key => {
result = isDef(result[key]) ? result[key] : '';
});
return result;
}
const camelizeRE = /-(\w)/g;//\w Indicates the underscore of numbers and letters
export function camelize(str: string): string {
return str.replace(camelizeRE, (_, c) => c.toUpperCase());
//toUpperCase Convert letters to Capitalization
}
export function isAndroid(): boolean {
/* istanbul ignore next */
return isServer ? false : /android/.test(navigator.userAgent.toLowerCase());
// Only on the non server side
// Determine whether it is an Android device
}
export function isIOS(): boolean {
/* istanbul ignore next */
return isServer ? false : /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
// Only on the non server side
// Judge whether it is ios equipment
}
export function range(num: number, min: number, max: number): number {
// Math.max Returns the largest number in a group
// Math.min The smallest of a group of several kinds returning to Shanghai
return Math.min(Math.max(num, min), max);
}
export function isInDocument(element: HTMLElement): boolean {
// stay ts j in dom Node type The type is HTMLElement
// The return value is boolean
return document.body.contains(element);
// document.body node Whether to include the target node
}
边栏推荐
- 示波器探头对测量带宽的影响
- AITM2-0002 12s或60s垂直燃烧试验
- Abnova丨培养细胞总 RNA 纯化试剂盒中英文说明书
- 解析五育融合之下的steam教育模式
- ts 之 属性的修饰符public、private、protect
- bazel是否有学习的必要
- Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
- Hdu2377bus pass (build more complex diagram +spfa)
- Abnova CD81 monoclonal antibody related parameters and Applications
- 示波器探头对信号源阻抗的影响
猜你喜欢

PVC 塑料片BS 476-6 火焰传播性能测定

培养机器人教育创造力的前沿科技

【案例】定位的运用-淘宝轮播图

Duchefa p1001 plant agar Chinese and English instructions

实现浏览页面时校验用户是否已经完成登录的功能

Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance

Clion-MinGW编译后的exe文件添加ico图标

Prosci LAG-3 recombinant protein specification

Analysis of steam education mode under the integration of five Education

台风来袭!建筑工地该如何防范台风!
随机推荐
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
实现浏览页面时校验用户是否已经完成登录的功能
CADD course learning (7) -- Simulation of target and small molecule interaction (semi flexible docking autodock)
Abnova丨血液总核酸纯化试剂盒预装相关说明书
Prosci LAG-3 recombinant protein specification
获取前一天的js(时间戳转换)
shell编程100例
使用WebAssembly在浏览器端操作Excel
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
Abbkine trakine F-actin Staining Kit (green fluorescence) scheme
Specification of protein quantitative kit for abbkine BCA method
培养机器人教育创造力的前沿科技
LeetCode: Distinct Subsequences [115]
序列联配Sequence Alignment
phpstudy小皮的mysql点击启动后迅速闪退,已解决
Duchefa cytokinin dihydrozeatin (DHZ) instructions
Interpreting the daily application functions of cooperative robots
当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
hdu2377Bus Pass(构建更复杂的图+spfa)