Jquery w2ui侧栏无法识别w2ui.sidebar
我正在寻找这个来源 我可以通过以下方式添加文件夹:Jquery w2ui侧栏无法识别w2ui.sidebar,jquery,w2ui,Jquery,W2ui,我正在寻找这个来源 我可以通过以下方式添加文件夹: $("#projectExplorer").w2sidebar({ name: "projectExplorer", nodes: [ { id: projectDir, text: projectName, img: "icon-folder", expanded: false, group1: true,
$("#projectExplorer").w2sidebar({
name: "projectExplorer",
nodes: [
{ id: projectDir, text: projectName, img: "icon-folder", expanded: false, group1: true,
nodes: [
{ id: scriptsDir, text: "Scripts", img: "icon-folder", group1: true, expanded: false },
{ id: shaderDir, text: "Shaders", img: "icon-folder", group1: true, expanded: false }
]
}
]
});\
但是,当我尝试动态添加以下内容时:
w2ui.sidebar.insert(parent, null, [
{ id: currentFile, text: _files[i], img: "icon-page" }
]);
我得到错误:TypeError:无法读取未定义的属性“insert”
我不知道w2ui.sidebar是从哪里来的,但它在上面链接中的示例代码中起作用,所以我认为它是库正在创建的某个全局变量,但显然它不在我的示例中,这导致了错误,但不知道现在该做什么。我相信您想要:
w2ui.projectExplorer.add(parent, { id: currentFile, text: _files[i], img: "icon-page" });
定义$projectExplorer.w2sidebar时,您正在创建一个ID为projectExplorer的w2sidebar。该示例之所以有效,是因为它们定义了$sidebar.w2sidebar