https://github.com/ihtml5/one-utils
Super useful utility tool library and run anywhere
https://github.com/ihtml5/one-utils
angular es2015 jscalpel loader react underscore utils vue wxapp
Last synced: 27 days ago
JSON representation
Super useful utility tool library and run anywhere
- Host: GitHub
- URL: https://github.com/ihtml5/one-utils
- Owner: ihtml5
- License: mit
- Created: 2017-10-26T09:45:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T02:52:34.000Z (over 7 years ago)
- Last Synced: 2025-01-18T20:37:22.569Z (about 1 year ago)
- Topics: angular, es2015, jscalpel, loader, react, underscore, utils, vue, wxapp
- Language: JavaScript
- Homepage: http://ihtml5.github.io/one-utils
- Size: 4 MB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# one-utils
Super useful utility tool library
> 兼容web,小程序
### Install using npm
[](https://npmjs.org/package/one-utils)
```
npm install one-utils --save
yarn add one-utils --save
```
## Api
### 1. initial
> 初始化oneUtils运行环境,创建实例
```javacript
const oneIns = oneUtils.create({ engine: wx || window });
```
### 2. [dom](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/querySelector)
> 根据运行环境不同,选择dom或者wxml
+ oneIns.querySelector(selector)
> 返回文档中与指定选择器或选择器组匹配的第一个Element
+ oneIns.querySelectorAll(selector)
> 选择界面所有符合条件的元素
### 3. [fetch](https://developer.mozilla.org/zh-CN/docs/Web/API/Fetch_API)
> 和web fetch用法相同
```javascript
oneIns.fetch({
url: 'http://github.com',
method: 'GET/POST',
header: {}, // custom request header,
body: {}, // submit data
}).then(res => console.log(res));
```