Vue el-tree同级节点上下移动并更新树状结构
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
免费下载资源
·
move(node, type) {
const data = node.data
const parent = node.parent
const children = parent.childNodes
const index = children.findIndex(d => d.data.id === data.id)
// 被移动的节点
const element = children[index]
if (type === 'up') {
if (index === 0) {
this.$message.warning('已经在首位了')
return
}
// 参照节点
const referenceNode = children[index - 1]
this.$refs.tree.remove(element)
this.$refs.tree.insertBefore(element.data, referenceNode)
} else if (type === 'down') {
if (index === children.length - 1) {
this.$message.warning('已经在末尾了')
return
}
const referenceNode = children[index + 1]
this.$refs.tree.remove(element)
this.$refs.tree.insertAfter(element.data, referenceNode)
}
},
GitHub 加速计划 / vu / vue
82
16
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:4 个月前 )
9e887079
[skip ci] 3 个月前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 6 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)