# Utils 说明

utils.js 自定义工具类
Author andy.ten@tom.com & xukaixing@hotmail.com

# API

# Utils Methods

方法名 说明 参数 示例
debounce 防抖函数 (func, wait = 100, immediate) debounce(this.remoteMethod, 500);
sleep 异步函数 (timeLen) sleep(500).then(()=>{ ... })
isString 判断是否是字符串 (str) isString(str) 返回值:Boolean
isArray 判断是否是数组 (arg) isArray(str) 返回值:Boolean
isNumber 判断是否是数字 (arg) isNumber(str) 返回值:Boolean
isExternal 判断路由是否是外部链接方法 (path) isExternal(path)
toLine 驼峰转下划线 (str) toLine(str)
toHump 下划线转驼峰 (str) toHump(str)
hasClass 判断是否包含class (ele, cls) hasClass(check, 'is-checked')
addClass 添加class (ele, cls) addClass(check, 'is-checked')
removeClass 删除class (ele, cls) removeClass(check, 'is-checked')
addClass 添加class (ele, cls) addClass(check, 'is-checked')
downloadTemplate 下载导入模版 (filename) downloadTemplate('importUsers.xls');
exportError excel导出错误信息 (headList, func, data, btnNode) exportError(this.importHead, url,
{ params});
removeAmountFormat 去除千位符方法 (val) removeAmountFormat(val)
amountFormat 转换千位符方法 (val, decimal = 2) amountFormat(val, 2)
addAsyncRoute 动态添加路由(横向tab页) (currentRouter, toRoute,
currentRoute)
addAsyncRoute(this.$router,
route, this.$route);
closeAsyncRoute 关闭动态添加路由(横向tab页) (currentRouter, currentRoute,
targetViewFullPath)
closeAsyncRoute(this.$router,
this.$route, path);
refreshAsyncRoute 刷新指定路由(横向tab页) (currentRouter, currentRoute,
targetViewFullPath, isGo)
refreshAsyncRoute(this.$router,
this.$route, path);
createCustomComponent 将指定组件设置自定义名称 (name, component) route.component =
createCustomComponent(asyncView[0].name,
route.component);

# 版本

  • v1.1.8