How to use ztree in vue (detailed tutorial)

亚连
Release: 2018-06-07 14:25:56
Original
5973 people have browsed it

This article mainly introduces how to use ztree in vue, including configuring package.json and automatically loading jquery. This article introduces you to it in great detail and has reference value. Friends who need it can refer to it

The following will introduce to you how to use vue ztree together, let’s take a look!

Configure package.json

Package and download jquery and ztree

"dependencies": { "element-ui": "^2.1.0", "vue": "^2.5.2", "axios": "^0.16.1", "jquery":"3.3.1", "vue-awesome":"2.3.4", "ztree":"3.5.24" },
Copy after login

Automatically load jquery

project jquery is automatically loaded during build and output to jQuery. jQuery is used in ztree.

plugins: [ new webpack.ProvidePlugin({ jQuery:'jquery', $:'jquery', }) ]
Copy after login

import jquery and ztree

import 'jquery' import 'ztree' import 'ztree/css/metroStyle/metroStyle.css'
Copy after login

Calling ztree to generate a tree structure

export default { data() { return { nodeData: [{ name: "父节点1", children: [ {name: "子节点1"}, {name: "子节点2"} ] }], setting:{ view: { showLine: false }, data: { simpleData: { enable: true } }, callback: { onClick: this.getFileDesc } } } }, mounted(){ let nodeData = this.nodeData $.fn.zTree.init($("#uploadtree"), this.setting, nodeData); } }
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to get node elements using JS

About the use of vue-fontawesome in vue.js

Add element new node using JS

The above is the detailed content of How to use ztree in vue (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn