未捕获的TypeError:无法读取zTree_v3库上未定义的属性’init’

我在使用zTree库时遇到了问题。 这是我的代码

<script type="text/javascript" src="asset/js/jquery-1.4.4.min.js"> <script type="text/javascript" src="asset/js/jquery.ztree.core-3.5.js">  <!-- var setting = { data: { simpleData: { enable: true } } }; var zNodes =[ { id:1, pId:0, name:"Custom Icon 01", open:true, iconOpen:"asset/img/diy/1_open.png", iconClose:"asset/img/diy/1_close.png"}, { id:11, pId:1, name:"leaf node 01", icon:"asset/img/diy/2.png"}, { id:12, pId:1, name:"leaf node 02", icon:"asset/img/diy/2.png"}, { id:13, pId:1, name:"leaf node 03", icon:"asset/img/diy/2.png"}, { id:2, pId:0, name:"Custom Icon 02", open:true, iconOpen:"asset/img/diy/1_open.png", iconClose:"asset/img/diy/1_close.png"}, { id:21, pId:2, name:"leaf node 01", icon:"asset/img/diy/8.png"}, { id:22, pId:2, name:"leaf node 02", icon:"asset/img/diy/8.png"}, { id:23, pId:2, name:"leaf node 03", icon:"asset/img/diy/8.png"} ]; $(document).ready(function(){ $.fn.zTree.init($("#treeDemo"), setting, zNodes); }); //-->  

我得到一些错误

未捕获的TypeError:无法读取未定义(匿名函数)b.extend.ready u的属性’init’

请帮帮我,我该如何解决这个问题? 谢谢

这是因为在多个地方包含了js。 我在我的Portal页面遇到了同样的问题,其中jquery-1.4.4.min.js和jquery.ztree.core-3.5.js被包含在很多地方。

我通过从该页面上的所有portlet中删除对js的所有引用来解决此问题,并以给定顺序在theme / _diff / portal_noraml.vm中全局添加这些js。

这个错误出现在$(document).ready() ,这是因为你的zTree脚本没有正确加载。 “无法读取未定义的属性’init’意味着你写了一些评估为undefined.init东西 – 所以你知道$.fn.zTree是未定义的。

如果您查看浏览器开发人员工具的网络选项卡,您应该会看到问题所在。 我猜它将是404(即标签的src属性不正确)或403(即你需要更改zTree文件的权限,以便web服务器可以读取它) 。