我在 Dynamics CRM 2015 中遇到了性能问题。我必须显示表单上提供的所有选项卡。所以我的 Javascript 代码如下所示:
Xrm.Page.ui.tabs.get().forEach(function (v, i) {
var performance1 = performance.now();
v.setVisible(true);
var performance2 = performance.now();
console.log(v.getName() + " show process took " + (performance2 - performance1) + " milliseconds.");
});
运行后,脚本在控制台中写入:
tab_10 show process took 4839.822311864544 milliseconds.
tab_13 show process took 5.218640743772994 milliseconds.
tab_14 show process took 4.996419017363223 milliseconds.
tab_7 show process took 3.8835254718323995 milliseconds.
tab_5 show process took 4.66844116813445 milliseconds.
tab_17 show process took 4.570270927553793 milliseconds.
tab_20 show process took 3.5970468606719805 milliseconds.
tab_8 show process took 3.7335927407548297 milliseconds.
tab_16 show process took 3.5988317741357605 milliseconds.
tab_15 show process took 5.135642267643561 milliseconds.
tab_12 show process took 3.6483631227965816 milliseconds.
tab_19 show process took 6.199896921247273 milliseconds.
为什么显示第一个元素需要超过4秒(!!!),当下一个元素需要2 - 5毫秒???
答案 0 :(得分:0)
使用CRM Performance center来捕获指标&研究组件明智的负载分析。
Xrm.Page.ui.controls.get("tabname").setVisible(true);
当为第一个控件执行上述语句setVisible
时,产品会呈现所有相关的DOM&脚本,因此约4秒。这减少了后续的电话。
这取决于浏览器以及它是如何工作的。
也许代替setVisible
,您可以使用setDisplayState
来减少数字。
Xrm.Page.ui.tabs.get("tabname").setDisplayState('collapsed');
Xrm.Page.ui.tabs.get("tabname").setDisplayState('expanded');