Super useful utility tool library
兼容web,小程序
npm install one-utils --save
yarn add one-utils --save
初始化oneUtils运行环境,创建实例
const oneIns = oneUtils.create({ engine: wx || window });
2. dom
根据运行环境不同,选择dom或者wxml
- oneIns.querySelector(selector)
返回文档中与指定选择器或选择器组匹配的第一个Element
- oneIns.querySelectorAll(selector)
选择界面所有符合条件的元素
3. fetch
和web fetch用法相同
oneIns.fetch({
url: 'http://github.com',
method: 'GET/POST',
header: {}, // custom request header,
body: {}, // submit data
}).then(res => console.log(res));