xrmm-tools
v1.3.3
Published
提供基础类型判断,数组对象操作等前端常用工具函数
Downloads
2
Readme
安装
npm i xrmm-tools
导入
import xrmm from 'xrmm-tools'
检查数据类型
//引入
import {
isArray,
isBoolean,
isDate,
isEmptyObj,
isFunction,
isNumber,
isObject,
isString,
} from "xrmm-tools";
//结果
console.log(isArray([])); //true
console.log(isBoolean(true)); //true
console.log(isDate(new Date())); //true
console.log(isEmptyObj({})); //true
console.log(isFunction(() => {})); //true
console.log(isNumber(12)); //true
console.log(isObject({})); //true
console.log(isString("")); //true
检查字符串后缀的文件类型
//引入
import { getFileType } from "xrmm-tools";
//结果
console.log(getFileType("test.pdf")); //pdf
console.log(getFileType("test.txt")); //txt
console.log(getFileType("test.doc")); //word
console.log(getFileType("test.docx")); //word
console.log(getFileType("test.xlsx")); //excel
console.log(getFileType("test.xls")); //excel
console.log(getFileType("test.png")); //picture
console.log(getFileType("test.jpg")); //picture
console.log(getFileType("test.jpeg")); //picture
console.log(getFileType("test.bmp")); //picture
过滤掉为空值的字段
//引入
import { filterEmptyParams } from "xrmm-tools";
const obj = {
name: "xr",
age: "18",
address: "",
email: undefined,
phone: null,
};
//结果
console.log(filterEmptyParams(obj)); //{ name: 'xr', age: '18' }
元素自适应窗口缩放
<div :style="style"></div>
//引入
import { resizeWindow } from "xrmm-tools";
let style = ref(null);
import { onMounted, ref } from "vue";
onMounted(() => {
style.value = resizeWindow();
window.addEventListener("resize", () => {
style.value = resizeWindow();
});
});
开源协议
ISC