当前位置:网站首页>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
}
边栏推荐
- Popular science | does poor English affect the NPDP exam?
- Influence of oscilloscope probe on measurement bandwidth
- MySQL InnoDB架构原理
- WPF gets the control in the datagridtemplatecolumn of the specified row and column in the DataGrid
- How to renew NPDP? Here comes the operation guide!
- shell编程100例
- MYSQL IFNULL使用功能
- Influence of oscilloscope probe on signal source impedance
- 显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
- Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
猜你喜欢

显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??

Open source SPL eliminates tens of thousands of database intermediate tables
MySQL fully parses json/ arrays

Abnova丨E (DIII) (WNV) 重组蛋白 中英文说明书

Cutting edge technology for cultivating robot education creativity

Prosci LAG-3 recombinant protein specification

ProSci LAG3抗体的化学性质和应用说明

XML建模

leetcode:1755. 最接近目标值的子序列和

Abnova CRISPR spcas9 polyclonal antibody protocol
随机推荐
Implementation of redis unique ID generator
研学旅游实践教育的开展助力文旅产业发展
SYSTEMd resolved enable debug log
MySQL fully parses json/ arrays
显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
Simple getting started example of Web Service
请查收.NET MAUI 的最新学习资源
解读协作型机器人的日常应用功能
Viewrootimpl and windowmanagerservice notes
Abnova blood total nucleic acid purification kit pre installed relevant instructions
解析五育融合之下的steam教育模式
线程池的使用
示波器探头对信号源阻抗的影响
Cutting edge technology for cultivating robot education creativity
Material design component - use bottomsheet to show extended content (II)
Popular science | does poor English affect the NPDP exam?
haas506 2.0开发教程 - 阿里云ota - pac 固件升级(仅支持2.2以上版本)
Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
leetcode:1139. 最大的以 1 为边界的正方形
Web Service简单入门示例