介绍
前端辅助函数库,包含常用的环境监测、资源加载、版本比较等
设置镜像:
npm set registry https://npm.voghion.com/
安装
cdn 方式引用
暂无
npm 方式引用
yarn add @voghion/fe-util
webpack 需配置后编译插件
yarn add webpack-post-compile-plugin
配置 webpack.config.js
const PostCompilePlugin = require('webpack-post-compile-plugin')
module.exports = {
...
plugins: [
new PostCompilePlugin(),
...
]
}
使用
import { getEnv, getSessionStorage } from '@voghion/fe-util'
const env = getEnv() // 获取环境实例
if (env.isIOS) {
console.log('in iOS')
}
const session = getSessionStorage() // 获取封装的 sessionStorage 实例