0.0.16 • Published 11 months ago
@hsdata/web-core v0.0.16
@hsdata/web-core
提供统一的 Vue 初始化,第三方组件的注入,vue 原型挂载等功能。
初始化已包含的功能
- Vue 实例化;
- dui-vue 注册、ant-design-vue 注册、vxe-table 注册;
- DUtils 挂载到 Vue 原型:
this.$DUtils
; - Storage 挂载到 Vue 原型:
this.$storage
,默认挂载localStorage
; - Io 挂载到 Vue 原型:
this.$io
、this.$get
、this.$post
、this.$upload
。
安装和使用
// 安装:
yarn add @hsdata/web-core
// 使用:
import WebCore from '@hsdata/web-core'
new WebCore(opts)
opts 配置说明
- Opts 配置项:Object
- el:
string | HTMLElement
,Vue 挂载的元素;默认:#app - render:
(h)=> h
,vue 渲染模板; - sysConfig:
Object
,系统配置参数,会挂载到 Vue 原型上,通过this.$$config
访问; - store:
Store
,必须是已实例化的 Store 对象; - router:
VueRouter
,必须是已实例化的 Router 对象; - duiConfig:
Object
,dui-vue 组件初始化的参数;默认:{ apiVersion:'v2' } - initBefore:
(VuePrototype,next)=> next()
,初始化之前的函数,必须调用 netx(); - initAfter:
(vue)=>{}
,初始化之后的函数,参数是实例化之后的 vue; - io:
Object
,通过 Dio 实例化的对象;
- el:
导出的功能
import {
Dio, // 和dui-vue库的IO用法一致
storage, // 当前已实例化的storage
sessionStorage,
localStorage,
cookie,
DUtils,
MutationTypes // vuex mutation的所有类型
} from '@hsdata/web-core'