vue-draggable-nested-tree icon indicating copy to clipboard operation
vue-draggable-nested-tree copied to clipboard

How to click the node to get the data of each node in the development scenario

Open zhanjunhao opened this issue 6 years ago • 10 comments
trafficstars

So let's say I want to click and get the data for each node how do I extend that by just adding the click event

zhanjunhao avatar Mar 05 '19 01:03 zhanjunhao

Tree(:data="data" draggable crossTree)
  div(slot-scope="{data, store, vm}" @click="yourmethod(data)")
    //- data is node
    //- store is the tree
    //- vm is node Vue instance, you can get node level by vm.level
    template(v-if="!data.isDragPlaceHolder")
      b(v-if="data.children && data.children.length" @click="store.toggleOpen(data)") {{data.open ? '-' : '+'}} 
      span {{data.text}}

phphe avatar Mar 05 '19 12:03 phphe

thank you I see 😄

zhanjunhao avatar Mar 06 '19 16:03 zhanjunhao

那个 添加了@click="yourmethod(data)" 获取当前节点数据 时 我想解析当前节点的数据 但是该对象 还在遍历循环中 控制台报错:Uncaught TypeError: Converting circular structure to JSON

zhanjunhao avatar Mar 07 '19 07:03 zhanjunhao

那个 添加了@click="yourmethod(data)" 获取当前节点数据 时 我想解析当前节点的数据 但是该对象 还在遍历循环中 控制台报错:Uncaught TypeError: Converting circular structure to JSON use tree.pure

// with children
div(slot-scope="{data, store, vm}" @click="yourmethod(store.pure(data, true))")
// without children
div(slot-scope="{data, store, vm}" @click="yourmethod(store.pure(data))")

phphe avatar Mar 07 '19 07:03 phphe

ok, you are good!

zhanjunhao avatar Mar 07 '19 07:03 zhanjunhao

Tree events change Event the third parameter oldTree returns null and does not fetch the oldTree structure

zhanjunhao avatar Mar 07 '19 09:03 zhanjunhao

Tree events change Event the third parameter oldTree returns null and does not fetch the oldTree structure

old tree exists when drag cross tree

phphe avatar Mar 07 '19 10:03 phphe

What kind of situation is the existence of the old tree can not try out

zhanjunhao avatar Mar 08 '19 02:03 zhanjunhao

https://github.com/phphe/vue-draggable-nested-tree/blob/master/src/components/DraggableTreeNode.vue#L61 check the source code, line 61 to 68

phphe avatar Mar 13 '19 13:03 phphe

O I see

zhanjunhao avatar Mar 14 '19 01:03 zhanjunhao