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 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐