vue-draggable-nested-tree实现可拖拽的树节点示例代码

代码语言:html

所属分类:拖放

代码描述:vue-draggable-nested-tree实现可拖拽的树节点示例代码,可无限增加树的层级结构。

代码标签: vue draggable nested tree 拖拽 节点 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap.4.0.0-alpha.6.css">
<style>
#app {
  padding: 50px;
}

.he-tree {
  border: 1px solid #ccc;
  padding: 20px;
}

.tree-node-inner {
  padding: 5px;
  border: 1px solid #ccc;
  cursor: pointer;
}

.draggable-placeholder-inner {
  border: 1px dashed #0088F8;
  box-sizing: border-box;
  background: rgba(0, 136, 249, 0.09);
  color: #0088f9;
  text-align: center;
  padding: 0;
  display: flex;
  align-items: center;
}

.tree3 .tree-node-inner {
  border: none;
  padding: 0px;
}
.tree3 .tree-node-inner-back:hover {
  background: #ddd;
}

.tree4 .tree-node-inner {
  border: none;
  border-bottom: 1px solid #ccc;
  padding: 5px 10px;
  backgroud: #ccc;
}
.tree4 .draggable-placeholder-inner {
  background-color: orangered;
}
</style>

  
  
</head>

<body translate="no">
  <div id="app">
  <div class="row">
    <div class="col-3">

      <Tree :data="tree1data" draggable="draggable" cross-tree="cross-tree">
        <div slot-scope="{data, store}">
          <template v-if="!data.isDragPlaceHolder"><b v-if="data.children &amp;&amp; data.children.length" @click="store.toggleOpen(data)">{{data.open ? '-' : '+'}}&nbsp;</b><span>{{data.text}}</span></template>
        </div>
      </Tree>
    </div>
    <div class="col-3">
      <Tree :data="tree2data" draggable="draggable" cross-tree="cross-tree">
        <div slot-scope="{data, store}">
          <template v-if="!data.isDragPlaceHolder"><b v-if="data.children &amp;&amp; data.children.length" @click="store.toggleOpen(data)">{{data.open ? '-' : '+'}}&nbsp;</b><span>{{data.text}}</span></template>
        </div>
      </Tree>
      <div class="mt-2">
        <button class="btn btn-primary" @click="addChild">Add child</button>
      </div>
    </div>
    <div class="col-3">
      <Tree class="tree3" :data="tree3data" draggable="draggable" cross-tree="cross-tree">
        <div slot-scope="{data, store}">
          <template v-if="!data.isDragPlaceHolder"><b v-if="data.children &amp;&amp; data.children.length" @click="store.toggleOpen(data)">{{data.open ? '-' : '+'}}&nbsp;</b><span>{{data.text}}</span></template>
        </div>
      </Tree>
    </div>
    <div class="col-3">
      <Tree class="tree4" :data="tree4data" draggable="draggable" cross-tree="cross-tree" :indent="30" :space="0">
        <div slot-scope="{data, store}">
          <template v-if="!data.isDragPlaceHolder"><b v-if="data.children &amp;&amp; data.children.length" @click="store.toggleOpen(data)">{{data.open ? '-' : '+'}}&nbsp;</b><span>{{data.text}}</span></template>
        </div>
      </Tree>
    </div>
  </div>
</div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script>
<script type="text/javascript" src="//repo.b.........完整代码请登录后点击上方下载按钮下载查看

网友评论0