1.8.0 • Published 1 year ago

nw-design v1.8.0

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

nw-design

基于element-ui封装的部分组件

install

npm i nw-design

引入

全局引入

在引入element之后,在main.js全局引入

import NwDesign from "nw-design";
Vue.use(NwDesign);

局部引入

import {NwTable} from 'nw-design'
export default {
  components: {
    NwTable
  }
}

组件

nw-table

nw-table是基于el-table二次封装的组件,主要用于展示本地数据表格和在线请求数据表格

props

参数说明类型可选值默认值
pageFormZore是否从0开始booleanfalse
url表格远程接口地址string
request远程数据请求对象,暂定于实例化的axios对象object
methods表格远程接口请求方法stringget/postget
showSelection是否显示勾选框booleanfalse/truefalse
showRadio是否显示单选框booleanfalse/truefalse
radioKey单选框绑定的属性需要唯一值当showRadio为true的时候该属性必填string
showIndex是否显示序号booleantrue/falsetrue
searchParams查询参数object{}
localData本地数据array[]
columns表格列数据array[]
searchParams查询参数object{}
reserveSelection仅对 type=selection 的列有效,类型为 Boolean,为 true 则会在数据更新之后保留之前选中的数据(需指定 row-key)booleanfalse
pagination是否显示分页(本地数据和远程数据均可自动分页)boolentrue/falsetrue
pageSizes页码选择array10, 20, 30, 50
pageAlign分页器水平对齐方式stringstart(左对齐)/center(居中)/end(右对齐)start
pagemap关于请求数据分页字段的映射object{page: "page",size:"size"}
datamap关于数据返回字段映射object{total: "total",list:"list"}
pageLayout分页布局string'total, sizes, prev, pager, next, jumper'
psize每页多少条记录number10

以上为封装的table特有的属性,另外自动继承了el-table的其他属性,也可直接使用,关于el-table的events也可以直接使用。

methods

组件内部有很多方法,以_开头的统一定义为组件内部方法,尽量不要直接使用,暴露的方法有: | 方法名 | 说明 | 参数
| -------- | :----- | :----- | resetTable | 重置表格,包括将当前页重置为第一页 | — | refreshTable | 刷新表格,不重置当前页 | —

events

事件名说明参数
radio-change当用户勾选单选框的时候触发的事件row

columns

关于表格列的格式基本同Table-column,只不过以对象的形式配置 eg:

{
  type: "expand",
  slot: "expand",
  width: 55,
  align: "ecnter"
},
{
  prop: "id",
  label: "商品id",
},
{
  prop: "name",
  label: "商品名称",
},
{
  prop: "desc",
  label: "描述",
}

组件的各种用法可在example.vue中查看

页面缓存

关于列表页和详情页的数据缓存,暂时使用keep-alive解决

nw-dialog

nw-dialog是基于el-dialog二次封装的组件,主要用于展示弹出框

props

参数说明类型可选值默认值
showFooter是否显示尾部booleantrue/falsefalse
showOk是否显示确定按钮booleantrue/falsefalse
okText确定按钮文字string确定
showCancel是否显示取消按钮booleantrue/falsefalse
cancelText取消按钮文字string取消
autoClose点击取消是否自动关闭弹框booleantrue/falsetrue
autoDestroy弹框隐藏是否自动销毁组件booleantrue/falsefalse
footerAlign尾部按钮对齐方式stringstart/center/endend

以上为封装的table特有的属性,另外自动继承了el-table的其他属性,也可直接使用,关于el-table的events也可以直接使用。

methods

组件内部有很多方法,以_开头的统一定义为组件内部方法,尽量不要直接使用,暴露的方法有: | 方法名 | 说明 | 参数
| -------- | :----- | :----- | show | 显示弹框 | — | hide | 隐藏弹框 | —

events

事件名说明参数
ok-click用户点击确定按钮的事件
cancel-click当用户点击取消按钮触发

其他props跟el-dialog组件一样

1.8.0

1 year ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago