1.0.16 • Published 4 years ago
thepaper-utils
Licence
ISC
Version
1.0.16
Deps
0
Size
81 kB
Vulns
0
Weekly
0
澎湃前端工具库
Install
支持打包压缩版(x.min.js)和非压缩版本(x.js)。
支持 AMD/CJS/ESM 模块引入。
支持通过script脚本直接引入链接。
// ESM
import * as utils from 'thepaper-utils';
//cjs
const Tool = require('thepaper-utils');
// AMD
require(['thepaper-utils'],function(){
...
})
// script 脚本
<script src="https://xxx.com/thepaper-utils.min.js"></script>
npm i thepaper-utils
yarn add thepaper-utils
Usage
import utils from 'thepaper-utils'
| 方法 | 调用 | 说明 | 返回 |
|---|---|---|---|
| iosOrAndroid | utils.iosOrAndroid() | 判断当前所在的环境 | ios\android\undefined |
| checkCode | utils.checkCode(value, type) | value: 传入需要验证的值 type: phone\mail\idcard\account\number |
true\false |
| getQuery | utils.getQuery() | 获取url的参数 | {id: 'xxx', age: 'xxx'} |
| wxShare | utils.wxShare(wxConfig, shareData) | 微信分享 | wxConfig: { appId, timestamp, nonceStr, signature, jsApiList(非必选) } shareData: { title, link, imgUrl, desc } |
<script src="" rel="nofollow noreferrer noopener" target="_blank">https://xxx.com/thepaper-utils.min.js">
调用方法同上,暴露出来的是 utils
Use One
import utils from 'thepaper-utils';
console.log(utils.iosOrAndroid());
Use Two
<script src="https://xxx.com/thepaper-utils.min.js"></script>
<script>
console.log(utils.iosOrAndroid())
</script>