GithubHelp home page GithubHelp logo

vue-ztree-2.0's Introduction

vue-ztree-2.0

安装步骤:

  npm install  vue-ztree-2.0

vue-ztree-2 演示预览地址

Vue小伙伴交流群: 590688906

通过以下demo来实现

main.js 代码如下

  import Vue from 'vue'
  import App from './App'
  import router from './router'
  import vueztree from 'vue-ztree-2.0/dist/vue-ztree-2.0.umd.min.js'
  import 'vue-ztree-2.0/dist/vue-ztree-2.0.css'

  Vue.use(vueztree)

  /* eslint-disable no-new */
  new Vue({
    el: '#app',
    router,
    template: '<App/>',
    components: { App }
  })

app.vue代码如下

<template>
  <div id="app">
    <h1>{{ msg }}</h1>
    <div style='width:280px;'>
      <vue-ztree :list.sync='ztreeDataSource' :func='nodeClick' :expand='expandClick' :contextmenu='contextmenuClick' :is-open='true'></vue-ztree>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      msg: 'Hello Vue-Ztree-2.0!',
      ztreeDataSource:[{
                id:1,
                name:"音乐",
                children:[],
                url:"http://www.baidu.com"
      },{
          id:2,
          name:"视频",
          children:[{
             id:3,
             name:"电影",
             children:[{
                id:4,
                name:"国产电影",
                url:""
             },{
                id:5,
                name:"好莱坞电影",
                url:""
             },{
                id:6,
                name:"小语种电影",
                url:""
             }]
          },{
             id:7,
             name:"短片",
             children:[{
                id:9,
                name:"电视剧",
                url:""
             },{
                id:10,
                name:"短片",
                url:""
             }]
          }]
      }]
    }
  },
  methods:{
    // 点击节点
    nodeClick:function(m){
       console.log(JSON.parse(JSON.stringify(m)));
    },
    // 右击事件
    contextmenuClick:function(m){
       console.log(m)
       console.log("触发了自定义的contextmenuClick事件");
    },
    // 点击展开收起
    expandClick:function(m){
       console.log(JSON.parse(JSON.stringify(m)));
       // 点击异步加载
       if(m.isExpand) {
          // 动态加载子节点, 模拟ajax请求数据
         // 请注意 id 不能重复哦。
         if(m.hasOwnProperty("children")){
            
            m.loadNode = 1; // 正在加载节点

            setTimeout(()=>{

              m.loadNode = 2; // 节点加载完毕

              m.isFolder = !m.isFolder; 

              m.children.push({
                  id:+new Date(),
                  name:"动态加载节点1",
                  path:"",
                  clickNode:false,
                  isFolder:false,
                  isExpand:false,
                  loadNode:0,
                  children:[{
                        id:+new Date()+1,
                        name:"动态加载末节点",
                        path:"",
                        clickNode:false,
                        isExpand:false,
                        isFolder:false,
                        loadNode:0
                  }]
              })
            },1000)
            
         }
       }
    }
  }
}
</script>

<style>
body {font-family: Helvetica, sans-serif;}
</style>

vue-ztree/初始化参数

参数 类型 默认值 描述
list Array - 树的结构数据源
func Function - 点击节点事件
contextmenu Function - 右击节点事件
expand Function - 点击展开/收起的方法(一般在异步加载的时候使用, 非异步加载传null)
is-open Bealoon true 是否展开树

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

For detailed explanation on how things work, consult the docs for vue-loader.

vue-ztree-2.0's People

Contributors

lisiyizu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-ztree-2.0's Issues

现版本出现错误的情况

This dependency was not found:

  • @/views/Main in ./src/router/index.js

To install it, you can run: npm install --save @/views/Main

-------------------------------更正方法---------------------------
"src/router/index.js" 15 lines

  • import Main from '@/views/Main'
  • import Main from '@/views/main'

demo 小问题哈

demo的代码有点儿小问题
views下面的文件是main.vue
引入的是

import Main from '../views/Main'

作者可以改下哈,小问题,找不到文件

怎么触发选择框事件

选择框的事件怎么触发啊,我看源码里有ckFunc这个函数,但是我在组件上用:ck-func=函数名,点击这个函数名的时候也没法触发,

选择框

不支持选择框吗?冲着复选框来的啊

把你的东西直接放我的后台程序里面 就不出结果了 我这边用的是服务端渲染 SSR

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

found in

--->
at D:\vue\wgssr\src\components\vue-ztree.vue
at D:\vue\wgssr\src\views\tree.vue
at D:\vue\wgssr\src\App.vue

把你的东西直接放我的后台程序里面 就不出结果了 我这边用的是服务端渲染 SSR

vue使用报错

You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
您使用的是仅运行时的 Vue 内部版本,其中模板编译器不可用。将模板预编译为呈现函数,或使用编译器包含的生成

复制示例,啥也没有改动,就这样 ,希望大神能解答

vue.runtime.esm.js?2b0e:619 [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

found in

--->
at vue-ztree.vue
at src/views/Test.vue
at src/views/RouterViewPage.vue... (1 recursive calls)
at src/App.vue

如何保持展开单一路径

需求是要始终保持单一路径展开,但是现有的代码我没有发现有这个功能,该怎么做呢?

请问如何在初始时让节点前面都显示“+”号? 非常感谢!

你好!
之前使用过您这个代码,也提个2个小问题。现在,我有个小的需求,想请教一下。我的需求是:希望节点前面初始的时候都显示“+”号,在“expandClick”里去动态请求数据,如果没有子节点,就不再显示“+”号,变为正常叶子节点的显示。 这个可能对您很简单,但我是个新手,也不太熟悉您的控件,看了几遍代码也还没有头绪。所以,请教一下您。希望得到您的帮助,非常感谢!
李栋

异步加载的bug

点击需要展开的节点,在异步事件响应之前再点击就会返回两遍

引入文件总是alert“哈哈”

npm安装后,在main.js文件中引入import vueztree from 'vue-ztree-2.0/dist/vue-ztree-2.0.umd.min.js',在引用时总是弹出哈哈,查找到的原因为vue-ztree-2.0.umd.min.js文件中有弹出"哈哈",删掉即可。
我的项目是用vue-cli建成

有时不能全部展开

你好!
我正在尝试使用的的控件。首先非常感谢!
我的tree一共又4级。使用控件时发现,有时只能显示2级,有时3级,有时可以4级全部显示。看了log,4级的数据都已经有了。因为刚刚开始使用vue,不是很熟,希望能给我一些解决这个问题的思路。或者能亲自解决一下。 再一次表示感谢!

//

你这个能结合select的选择框做一个不,并且多选的,这个组件好像还没人做过

vue-cli 3.0 下面, 会报错

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

异步加载展开菜单报错

bug
异步加载点击按钮总是报Cannot read property 'length' of undefined",虽然不影响使用,但看着好难受,有没有知道怎么解决的?

点击节点 获取所有父节点的路径

您好,
我想要点击一个节点文件,获取到从根节点到它父节点的path,有这项操作吗?
比如说,我点击了 data/img/3.png3.png
有没有哪个变量代表的是 data/img
谢谢

是否支持简单的 json data

ep:

var nodes = [
	{id:1, pId:0, name: "父节点1"},
	{id:11, pId:1, name: "子节点1"},
	{id:12, pId:1, name: "子节点2"}
];

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.