Skip to content

Commit

Permalink
to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaxincui committed Nov 7, 2017
1 parent 4c95cb3 commit 6a2a90e
Show file tree
Hide file tree
Showing 11 changed files with 3,573 additions and 3,473 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
不止这些,

- 增删改事件支持
- 可选的增删改功能
- 复选框显示可选
- 初始化勾选
- 可选的按钮图标
- 支持双击添加子节点
- 父节点半选状态
- 自定义显示字段
- 增、删、改显示可选
- ...


Expand All @@ -38,14 +37,17 @@ npm install vue-simple-tree --sve-dev
## 数据格式

`tree.json`
> `id`必要字段,且只能以`id`表示
> `name`必要字段,默认`name`,如要自定义如`display_name`,在`options`里定义`itemName:'display_name'`
> `children`非必要,如果有以数组表示
```json
{
"data": {
// id,必须字段,且字段名只能是id
"id": "1",
// name,必须字段,字段名可任意如display_name,如不是默认name须在options.itemName设置
"name": "Root",
// children,非必需,如果有以数组出现
"children": [
{
"id": "2",
Expand Down Expand Up @@ -183,22 +185,21 @@ options: {
## 事件
`add-a-child`、 `item-edit` 、`item-delete` 分别为添加子节点、编辑节点、删除节点事件。
`item-click`、`add-a-child`、 `item-edit` 、`item-delete` 分别为点击节点、添加子节点、编辑节点、删除节点事件。
这3个事件唯一做的就是传递当前id到监听器,`增`、`删`、`改`操作在自定义的监听方法里处理后更新`treeData`并传递到视图。
这些事件绑定了操作id到监听器
## 监听器
如果需要,你可以选择绑定这些事件的其中一个或多个。
> 注意:叶子节点双击事件也会触发`add-a-child`
```html
<vue-tree
:tree-data="treeData"
:options="options"
@add-a-child="addAChild"
@item-edit="itemEdit"
:tree-data="treeData"
:options="options"
@add-a-child="addAChild"
@item-click="itemClick"
@item-edit="itemEdit"
@item-delete="itemDelete">
</vue-tree>
```
Expand All @@ -210,6 +211,9 @@ methods: {
addAChild(id) {
console.log('点击了添加子节点按钮,父节点ID[' + id + ']')
},
itemClick(id) {
console.log('点击了节点,节点ID[' + id + ']')
},
itemEdit(id) {
console.log('点击了编辑按钮,节点ID[' + id + ']')
},
Expand All @@ -232,14 +236,14 @@ methods: {

`.vue-tree .item-wrapper .item-btn`

`.vue-tree .item-wrapper .item-btn .add-btn`

`.vue-tree .item-wrapper .item-btn .edit-btn`

`.vue-tree .item-wrapper .item-btn .delete-btn`

`.vue-tree-list`

`.vue-tree-list .tree-add`

## License

[MIT](https://github.com/jiaxincui/vue-tree/blob/master/LICENSE.md) © [JiaxinCui](https://github.com/jiaxincui)
2 changes: 1 addition & 1 deletion dist/static/css/app.css

Large diffs are not rendered by default.

330 changes: 173 additions & 157 deletions dist/static/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/static/js/app.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/static/js/manifest.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a2a90e

Please sign in to comment.