1.0.1 • Published 3 years ago

php2jsutils v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

php2jsutils

安装使用

npm i php2jsutils
  1. script标签直接引入

    <script src="../path/php2jsUtils.umd.js"></script>

    对外暴露变量名称为utils

    let {ajax,array_chunk}=utils;
  2. import方式引入

    import {array_chunk,ajax} from "php2jsutils";

数组函数

  • array_chunk
  • array_column
  • array_combine
  • array_count_values
  • array_diff
  • array_fill
  • array_filter
  • array_intersect
  • array_unique
  • array_last
  • array_first
  • array_map
  • array_merge
  • array_pad
  • array_pop
  • array_product
  • array_push
  • array_rand
  • array_reduce
  • array_reverse
  • array_search
  • array_shift
  • array_slice
  • array_splice
  • array_sum
  • array_unshift
  • count
  • in_array
  • range
  • shuffle

对象函数

  • is_plain_object
  • obj_change_key_case
  • obj_diff
  • obj_fill
  • obj_intersect
  • obj_keys
  • obj_values
  • obj_key_exists

字符串函数

  • explode
  • implode
  • lcfirst
  • rtrim
  • ltrim
  • nl2br
  • number_format
  • parse_str
  • str_contains
  • str_end_with
  • str_pad
  • str_repeat
  • str_replace
  • str_shuffle
  • str_split
  • str_start_with
  • strstr
  • strip_tags
  • stripos
  • strrchr
  • strrev
  • strtoupper
  • strtolower
  • substr
  • trim
  • ucfirst

日期函数

  • date
  • checkdate
  • date_add
  • date_create_from_format
  • date_diff
  • date_parse
  • date_sub
  • getdate
  • date_offset_get
  • gettimeofday
  • localtime
  • mktime

数据请求函数

  • ajax

ajax函数说明

  1. 调用方式一

    ajax({ url:"http://localhost:3000/posts/1", method:"get", headers: { "Content-Type": "application/json" }).then(res => { console.log(res) });

  2. 调用方式二

    ajax.get("http://localhost:3000/posts/1",{ headers: { "Content-Type": "application/json" }).then(res => { console.log(res) });

    支持的方法 request,get,post,put,delete

  3. 默认参数

    url: '',
    method: 'get',
    data: {},
    timeout: 0,
    responseType: 'json',// arraybuffer  json text  bolb
    headers: {},
    cancelToken: null,
    async: true,
    adapter: 'xhrAdapter',// xhrAdapter fetchAdapter