0.4.8 • Published 1 year ago

@varonervar/components v0.4.8

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

ElementUI二次封装组件库

基于Element-UI 封装常用组件,部分组件参考vue-element-admin


一. 版本须知

为避免异常问题,安装需锁定版本

稳定版本版本支持
0.4.7按需加载组件,初版

没有安装依赖库会提示错误

依赖库版本
Element-UI2.15.8(最新的2.15.9有bug不知道修复没,推荐使用2.15.8)
dayjs最新版本

二. 当前组件

不建议使用以及未完成的组件不会显示在下表

组件名称说明
ZTable配置化生成table表格,自带分页
ZForm配置化生成各种基础组件,支持水平多个
ZConditionstable的查询条件组件,配置同ZForm
ZObjectShow展示数据组件
ZUpload支持限制图片宽高,以及图片压缩
WlmLayout左侧菜单栏与顶部栏位,需要特定数据,针对当前管理系统

三. 安装

支持全局安装与按需加载,按需加载使用Element UI的babel-plugin-component

全局安装

推荐使用 npm 的方式安装,它能更好地和 webpack 打包工具配合使用,建议锁定版本号。

npm i @varonervar/components@稳定版本号 -S

CDN

目前可以通过 unpkg.com/@varonervar/components 获取到最新版本的资源,由于依赖Element-uidayjs,如果使用CDN,请先之前引入eleemnt-ui和dayjs的CDN。

<!-- 引入Element-ui 和dayjs,保证顺序在之前,不然报错 -->

<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/@varonervar/components/theme-chalk/lib/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/@varonervar/components/lib/index.js"></script>

:::tip 我们建议使用 CDN 引入 Element 的用户在链接地址上锁定版本,以免将来 Element 升级时受到非兼容性更新的影响。锁定版本的方法请查看 unpkg.com。 :::


四. 快速上手

完整引入

在 main.js 中写入以下内容:

import Vue from 'vue';
import ElementUI from 'element-ui';
import WlmComponent from '@varonervar/components'
import 'element-ui/lib/theme-chalk/index.css';
import '@varonervar/components/theme-chalk/lib/index.css';
import App from './App.vue';

Vue.use(ElementUI);
Vue.use(WlmComponent);

new Vue({
  el: '#app',
  render: h => h(App)
});

以上代码便完成了 @varonervar/components 的引入。需要注意的是,样式文件需要单独引入。

按需引入

借助 babel-plugin-component,我们可以只引入需要的组件,以达到减小项目体积的目的。

首先,安装 babel-plugin-component

npm install babel-plugin-component -D

然后,将 babel.config.js 修改为:

{
  "presets": [
    "@vue/cli-plugin-babel/preset"
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "@varonervar/components",
        "styleLibraryName": "~node_modules/@varonervar/components/theme-chalk/lib"
      }
    ]
  ]
}

接下来,如果你只希望引入部分组件,比如 ZTableZForm,那么需要在 main.js 中写入以下内容:

import Vue from 'vue';
import ElementUI from 'element-ui';
import { ZTable, ZForm } from '@varonervar/components';
import App from './App.vue';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);
Vue.component(ZTable.name, ZTable);
Vue.component(ZForm.name, ZForm);
/* 或写为
 * Vue.use(ZTable)
 * Vue.use(ZForm)
 */

new Vue({
  el: '#app',
  render: h => h(App)
});

完整组件列表和引入方式(完整组件列表以 src/index.js 为准)

import Vue from 'vue';
import {
  WlmLayout,
  ZConditions,
  ZForm,
  ZObjectShow,
  ZTable,
  ZUpload
} from 'element-ui';

Vue.use(ZUpload);
Vue.use(ZTable);
Vue.use(ZObjectShow);
Vue.use(ZForm);
Vue.use(ZConditions);
Vue.use(WlmLayout);

计划与分工

计划

  • 增加changelog
  • 增加单元测试
  • 增加沃平台包装组件

分工

开发人员开发组件
钟振业ProTable、ZRadioButton
卿松其他
0.4.8

1 year ago

0.3.9

2 years ago

0.4.5

2 years ago

0.3.6

2 years ago

0.2.7

2 years ago

0.4.4

2 years ago

0.3.5

2 years ago

0.4.7

2 years ago

0.3.8

2 years ago

0.4.6

2 years ago

0.3.7

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.3.4

2 years ago

0.4.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.8

2 years ago

0.2.6

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.2.3

2 years ago

0.1.4

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.1.6

2 years ago

0.2.4

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago