ahwater-prototype

1.3.23 • Public • Published

改写了vue3的支持 增加分辨率提示关闭功能

window 基础类型原型扩展工具。


对window、string、array、date、vue对象进行扩展


安装

via npm:

npm install pinyin

用法

开发者:

var Prototype = require("Prototype"); 

API - window

debounce window.debounce(fn[, delay])

防抖,不用多说

API - String

  • get

<Boolean> "abc".get("c")

从字符串中查询是否存在指定的字符/字符串

  • data_string

<String> "/Date(1333245600000+0800)/".data_string()

把长格式的时间 转换为 正常格式

  • getExt

<String> "aaaaa.shp".getExt()

对文件名的处理,提取字符串里面的最后一个点.后面的为后缀名

  • changeExt

<String> "aaaaa.shp".changeExt("bb")

更改后缀名

  • getName

<String> "aaaaa.shp".getName()

提取文件名

  • ClearBr

"ffff\r\nff".ClearBr()

字符串里面的换行符全部移除

  • Trim

<String> " aaa aa.shp ".Trim()

字符串里面的空白全部移除

  • getExt

<String> " aaaaa.shp ".TrimLeft()

字符串里面左侧的空白移除

  • getExt

<String> " aaaaa.shp ".TrimRight()

字符串里面右侧的空白移除

  • trimStartEnd

<String> " aaaaa.shp ".trimStartEnd()

字符串里面两侧的空白移除

  • IAN

<String> "123qw".IAN()

判断是否为由数字组成的字符串

  • has

<String> "aaaaa.shp".has("a")

判断是否存在指定字符

  • hases

<String> "aaaaa.shp".hases(["a","b"])

存在指定指定字符数组中的至少一个

  • hasno

<String> "aaaaa.shp".hasno("a")

判断是否不存在指定字符

API - Array

  • remove

[1,2,3,4,5].remove(3)

从数组中移除指定的值

  • clone

[1,2,3,4,5].clone()

浅拷贝数组对象

  • fresh

[1,2,3,4,5].fresh()

刷新数组

  • trim

[1,2,3,4,5].trim()

移除数组中空白

  • has

[1,2,3,4,5].has(2)

判断数组中是否存在指定项

API - Date

  • Format

date.Format([option])

日期格式化,默认为 "yyyy-MM-dd HH:mm"

  • Add

date.Add(option)

对象增加值,参数为对象格式 option.interval:y-年 q-季 M-月 w-周 d-天 h-时 m-分 s-秒 无-时间戳

API - Vue

  • loadingStart

this.loadingStart([fn])

开始loading,并执行回调函数(如果存在)

  • loadingStop

this.loadingStop([fn])

结束loading,并执行回调函数(如果存在)

  • $msg

this.$msg(option)

基于elementUI,简化message

  • $msgSuccess

this.$msg(option)

基于elementUI,简化message.success

  • $msgError

this.$msg(option)

基于elementUI,简化message.error

  • postMessage

this.postMessage(data,target)

传递消息

//example:
var dataJson = {    
    type: 'switchPage',
    className: 'Projects',
    refershFlag: true
}
this.postMessage(dataJson, '*');
//等同于 window.parent.postMessage(dataJson, '*');
  • openNewPage

this.openNewPage(url)

  • 返回随机数,限定长度length
  • 等同于window.open(url, "_blank");
  • log

this.log(object[,object2])

控制台记录

  • has

this.has(object,key)

判断对象中是否存在键

  • objectArray_get_value2_by_key1_value1

this.objectArray_get_value2_by_key1_value1(array, key, value, key2)

从对象数组中,根据K-V找到对象,并根据K2找到V2

  • objectArray_set_value2_by_key1_value1

this.objectArray_set_value2_by_key1_value1(array, key, value, key2, value2)

从对象数组中,根据K-V找到对象,并根据K2设置V2

  • objectPropertyMerge

this.objectPropertyMerge( obj, key, value,flag)

对象属性融合

  • getGVerify

this.getGVerify( )

验证码

//example:
 this.verifyCode = new this.getGVerify("yzm");
 //1.在id为yzm的元素内填充canvas
 //2.返回验证码verifyCode

许可证

MIT

Package Sidebar

Install

npm i ahwater-prototype

Weekly Downloads

0

Version

1.3.23

License

MIT

Unpacked Size

163 kB

Total Files

7

Last publish

Collaborators

  • qichangzhang