# vue-sortable-tree
[![npm](https://img.shields.io/npm/v/vue-sortable-tree.svg?style=flat-square)](https://www.npmjs.com/package/vue-sortable-tree)
[Demo Link](http://examples.itrydo.com/vue-sortable-tree/index.html)
[Demo Link Source Code](https://github.com/wuyuedefeng/vue-sortable-tree/blob/master/example/src/components/Hello.vue)
**QQ交流群:** 424580388
## Install
vue version < 2.5
```
$ npm install vue-sortable-tree@1.1.0 --save [must < 1.2.0]
```
vue version >= 2.5
```
$ npm install vue-sortable-tree --save
```
### Global register
```javascript
import SortableTree from 'vue-sortable-tree'
Vue.component(SortableTree.name, SortableTree)
```
### Partial register
```javascript
import SortableTree from 'vue-sortable-tree'
// then in component
components: {
[SortableTree.name]: SortableTree
}
```
## Usage
```vue
<template>
<sortable-tree :data="treeData">
<template slot-scope="{item}">
<span>{{item.name}}</span>
</template>
</sortable-tree>
</template>
```
### Params
```vue
<sortable-tree :data="treeData" attr="name" childrenAttr="children" mixinParentKey="$parent" @changePosition="changePosition">
<template slot-scope="{item}">
<span>{{item.name}}</span>
</template>
</sortable-tree>
```
Property | Type | Default | Description
-------- | ---- | ------- | -----------
`data` | `Object` | - | Tree data source.
`attr` | `String` | `'name'` | A name of property in data source that will be display.
`childrenAttr` | `String` | `children` | A name of property in data source that contain children node.
`mixinParentKey` | `String` | `''` | A name of property that contain parent data.
`closeStateKey` | `String` | `''` | A name of property to determine the open/close state.
`draggable` | `Boolean` | `true` | Enable dragging the tree node.
Event | Parameter | Description
----- | --------- | -----------
`changePosition` | `{beforeParent, data, afterParent}` | Trigger when node position has been changed.
### 依赖 sass[scss] support
if your project can't support scss please add below dependence
```
npm install node-sass --save-dev
npm install sass-loader --save-dev
```
## Project demo image
![img](./example/src/assets/tree.png)
You can design your style easily with custom template.
**eg:**
![img](./example/src/assets/tree-ext.png)
没有合适的资源?快使用搜索试试~ 我知道了~
vue树可拖动拖动项目排序
共39个文件
js:18个
json:4个
vue:4个
需积分: 50 8 下载量 50 浏览量
2019-08-10
09:25:05
上传
评论 1
收藏 171KB ZIP 举报
温馨提示
vue树可拖动,拖动项目排序
资源推荐
资源详情
资源评论
收起资源包目录
vue树可拖动拖动项目排序.zip (39个子文件)
vue-sortable-tree-master
example
.babelrc 234B
config
index.js 1KB
prod.env.js 48B
dev.env.js 139B
test.env.js 132B
package.json 3KB
index.html 148B
package-lock.json 428KB
static
.gitkeep 0B
src
App.vue 254B
assets
tree-ext.png 54KB
tree.png 29KB
logo.png 7KB
main.js 360B
components
Hello.vue 2KB
SortableTree.vue 8KB
router
index.js 231B
.eslintrc.js 642B
.gitignore 132B
README.md 664B
.eslintignore 23B
.editorconfig 147B
build
dev-client.js 245B
utils.js 2KB
build.js 953B
webpack.prod.conf.js 4KB
check-versions.js 1KB
webpack.dev.conf.js 1KB
dev-server.js 2KB
webpack.test.conf.js 831B
webpack.base.conf.js 2KB
vue-loader.conf.js 307B
.postcssrc.js 196B
package.json 500B
package-lock.json 80B
.npmignore 7B
.gitignore 40B
lib
index.vue 9KB
README.md 2KB
共 39 条
- 1
资源评论
weixin_39841848
- 粉丝: 509
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功