1.0.13 • Published 3 years ago

hc-agg v1.0.13

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

HC-agg

Toast

import { Toast } from 'hc-agg'

Toast.show('I am toast', 3000)
参数说明类型必须默认值
text展示的文字String-
duration展示的时长毫秒(ms)3000

Loading

import { Loading } from 'hc-agg'

Loading.show('LOADING ...')
Loading.hide()
参数说明类型必须默认值
text展示的文字String-

Modal

import { Modal } from 'hc-agg'

// 自定义Modal,参数为jsNode
Modal.show(``)

// 场景宣传框
Modal.scene({
    title: '查看历史',
    description: '扫码查看历史信息',
    image: 'https://www.baidu.com/img/baidu_jgylogo3.gif'
})

Modal.hide()
参数说明类型必须默认值
title标题String-
description描述信息String-
image图片地址String-

Dialog

import { Dialog } from 'hc-agg'
Dialog.alert({
    title: '标题',
    description: '这是一段描述',
    buttonColor: '#ff4d4d',
    buttonText: '我知道了'
}).then(() => {
    // on close
})
参数说明类型必须默认值
title标题String‘提示’
description描述信息String-
buttonColor按钮颜色String-
buttonText按钮文字String‘确定’
Dialog.confirm({
    title: '标题',
    description: '这是一段描述',
    confirmColor: '#ff4d4d',
    confirmText: '确定',
    cancelColor: '#aaaba3',
    cancelText: '取消'
}).then(() => {
    // on confirm
}).catch(() => {
    // on cancel
})
参数说明类型必须默认值
title标题String‘提示’
description描述信息String-
confirmColor确认按钮颜色String‘#ff4d4d’
confirmText确认按钮文字String‘确定’
cancelColor取消按钮颜色String‘#000’
cancelText取消按钮吻戏String‘取消’

Http

import { Http } from 'hc-agg'

const options = {
    baseURL: 'https://api.yuecard.net',
    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
    timeout: 100000,
    loading: false,
    errorToast: true,
    withCredentials: false,
    interceptors: true
}

const http = new Http(options)
参数说明类型必须默认值
baseURL请求的基地址String-
timeout超时时间Number20000
loading加载提示Booleantrue
errorToast异常捕获展示Booleantrue
contentType内容类型Stringapplication/json; charset=UTF-8
interceptors拦截器,需要获取xhr时关闭Booleantrue
withCredentials跨域时是否发送cookieBooleanfalse

Utils

import { Utils } from 'hc-agg'
方法说明
hasClass(el, cName)判断是否含有某个class
addClass(el, cName)添加class
removeClass(el, cName)移除class
getLength(str)获取字符串真实长度
priceToFix(price)分-->元,保留两位小数
formatTime(time)格式化时间戳

用例:

const $root = document.getElementById('root')
Utils.addClass($root, 'hide')
Utils.removeClass($root, 'hide')
Utils.removeClass($root, '') // 删除该节点所有class

const time = new Date().getTime()
Utils.formatTime(time) // 2018-09-19 14:50

Cookie

import { Cookie } from 'hc-agg'
方法说明
set创建cookie
get读取cookie
remove删除cookie

用例:

创建Cookie:--------------------
Cookie.set('name', 'value')

有效期:7天
Cookie.set('name', 'value', { expires: 7 })

有效期:7天   路径:当前页
Cookie.set('name', 'value', { expires: 7, path: '' })

读取Cookie:--------------------
Cookie.get('name')

读取所有Cookie:
Cookie.get()

删除Cookie:--------------------
Cookie.remove('name', { path: '' })

更多Cookie用法

Clipboard

<span id="Clipboard" data-clipboard-text="复制到粘贴板">复制到粘贴板</span>
import { Clipboard } from 'hc-agg'

const $span = document.getElementById('Clipboard')
const c = new Clipboard($span) // 点击span后即可复制到粘贴板
1.0.13

3 years ago

1.0.12

5 years ago

1.0.10

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago