Coder Social home page Coder Social logo

maurojr / vue-drag-tree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shuirong/vue-drag-tree

0.0 2.0 0.0 425 KB

Vue's Drag And Drop Tree Components || Demo

Home Page: https://vigilant-curran-d6fec6.netlify.com/#/

License: MIT License

Vue 100.00%

vue-drag-tree's Introduction

vue-drag-tree

VersionDownloadsLicenseTravisCIDependency

It's a tree components(Vue2.x) that allow you to drag and drop the node to exchange their data .

Feature

  • Double click on an item to turn it into a folder
  • Drag and drop the tree node, even between two different levels

中文 || Please Star it ,if it's helpful.

Demo


demo

Getting Start


Install

npm install vue-drag-tree --save

Usage

A Simple Project Using vue-drag-tree

main.js

import Vue from 'vue'
import VueDragTree from 'vue-drag-tree'

Vue.component('vue-drag-tree', VueDragTree)

test.vue

<template>
	<vue-drag-tree :model='data' :current-highlight='true' :default-text='"New A Girl"' :hover-color='"lightblue"' :highlight-color='"green"'></vue-drag-tree>
</template>
<script>
export default{
  data(){
    return{
      data:{
        name: 'Root',
        id: 0,
        children: [
          {
            name: 'Node 1-1',
            id: 1,
            children: [
              {
                name: 'Node 2-1',
                id: 2
              }
            ]
          },
          {
            name: 'Node 1-2',
            id: 3
          }
        ]
      }
    }
  },
  methods: {
    assignData(data) {
      // data is a json object that node infomation was exchanged inside.You need to assign to finish the last step of exchange.
      
      // If you have not use vuex or something similar, you can just assign data to this.data
      this.data = data
      
      // If you have used vuex or something similar, you need to write assign code by yourselft.
      // vuex as an example:
      // updateData function is a mutation of vuex. 
      
      // this.updateData(data)
    },
    curNodeClicked(model,component) {
      // information of the node clicked just now.
    },
  }
}
</script>

API


Attributes

property name description type default value
model tree's data (just like a json) object --
current-highlight need to highlight the node clicked ? boolean false
default-text the text of node that added String New Node
hover-color the background color when mouse over the node String #E5E9F2
highlight-color the background color when the node is clicked String #99A9BF

Methods

method name description parameter
assignData tree data that node is exchanged inside.what you need to do is assign this data to your former tree data. this method is provided for the one that used vuex in project mainly. (data) data: the tree object
curNodeClicked is provided for telling you which node is clicked and component the node is belong to (model,component) model: current node and children's data. component: current node's component

License


MIT

vue-drag-tree's People

Contributors

dkhjmu avatar droooney avatar shuirong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.