zTree在项目中的封装

229 阅读1分钟

Tree 是一个依靠 jQuery 实现的多功能 “树插件”。优异的性能、灵活的配置、多种功能的组合是 zTree 最大优点。

直接上代码

 (function(){
	let $ZTree = (id,url)=>{
		this.id = id;
		this.url = url;
		this.onClick = null;
		this.settings = null;
	}
	$ZTree.prototype = {
		initSetting:{},
		setSettings:{},
		init:{}
	}
	window.$ZTree = $ZTree;
 })()

手动设置ztree的设置

  setSettings:()=>{}

初始化ztree

 const nodes = 根据this.url获取的数据;
 $.fn.zTree.init($("#" + this.id), this.setting, nodes);

项目中的应用

ztree = new $ZTree(id, url);
ztree.setSettings(setting);
ztree.init();