- 注册时间
- 2021-5-27
- 最后登录
- 2021-10-26
- 阅读权限
- 10
- 积分
- 20
- 精华
- 0
- 帖子
- 3
|
felt 发表于 2021-6-29 09:10
请提供一个例子页面,我们来分析优化
例子我造好了,在treeSelect.html这个页面上改的;
问题现象就是,每次先点'生成下拉树'按钮再点'清空',点的越多,mini.parse方法越慢
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TreeSelect 树形选择框</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link href="./css/demo.css" rel="stylesheet" type="text/css"/>
<script src="./scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<div id="contentArea" ></div>
<button id="createAll" onclick="createManyTreeSelect()">生成下拉树</button>
<button id="clearAll" onclick="clearAllTreeSelect()">清空</button>
<script type="text/javascript">
var dataArr='[{id:"base",text:"Base",children:[{id:"ajax",text:"Ajax",pid:"base"},{id:"json",text:"JSON",pid:"base"},{id:"date",text:"Date",pid:"base",checked:true},{id:"control",text:"Control",pid:"base"},{id:"forms",text:"Forms",pid:"base",children:[{id:"button",text:"Button",pid:"forms"},{id:"listbox",text:"ListBox",pid:"forms"},{id:"checkboxlist",text:"CheckBoxList",pid:"forms"}]}]},{id:"lists",text:"Lists",children:[{id:"datagrid",text:"DataGrid",pid:"lists"},{id:"tree",text:"Tree",pid:"lists"},{id:"treegrid",text:"TreeGrid",pid:"lists"}]},{id:"layouts",text:"Layouts",children:[{id:"panel",text:"anel",pid:"layouts"},{id:"splitter",text:"Splitter",pid:"layouts"},{id:"layout",text:"Layout ",pid:"layouts"}]},{id:"navigations",text:"Navigations",children:[{id:"toolbar",text:"Toolbar",pid:"navigations"},{id:"tabs",text:"Tabs",pid:"navigations"},{id:"outlookbar",text:"OutlookBar",pid:"navigations"},{id:"menu",text:"Menu",pid:"navigations"},{id:"pager",text:"ager",pid:"navigations"}]},{id:"other",text:"Other",isLeaf:false,asyncLoad:false}]';
function createManyTreeSelect(){
var str = '';
for (var i = 0; i < 200; i++) {
str+="<input id=\"select"+i+"\" class=\"mini-treeselect\" multiSelect=\"true\"\n" +
" textField=\"text\" valueField=\"id\" parentField=\"pid\" checkRecursive=\"false\"\n" +
" showFolderCheckBox=\"true\" expandOnLoad=\"true\" showClose=\"true\" oncloseclick=\"onCloseClick\"\n" +
" popupWidth=\"200\"/>"
}
$('#contentArea').append(str);
var start= new Date();
mini.parse();
var end = new Date();
console.log(end-start);
for (var i = 0; i < 200; i++) {
var myTree = mini.get('select'+i);
myTree.set({
data.extend(true, [], eval(dataArr)),
valueField:'id',
parentField:'pid'
});
}
}
function clearAllTreeSelect(){
$('#contentArea').empty();
}
</script>
</body>
</html> |
|