简体   繁体   English

离子框架中的性能问题

[英]Performance issue in ionic framework

I have created the table with 50 rows and gave the css overflow is scroll to parent element of table. 我创建了具有50行的表,并给出了CSS溢出滚动到表的父元素的信息。 Each time of scrolling I will add 5 row in the table. 每次滚动时,我都会在表中添加5行。 It's working fine in html. 在html中工作正常。 But I converted this to ionic framework, I got performance lag. 但是我将其转换为离子框架,但性能却滞后。 Can any one suggest, why performance issue is occurring when perform DOM operation in ionic framework? 谁能提出建议,为什么在离子框架中执行DOM操作时会出现性能问题?

Remember to use the one-time-binding operator '::' in every angular directive that should execute or evaluate only once, I mean if you don't need to be watching for changes (ng-click, ng-class, ng-if, ng-switch...) and also in labels, texts, fields and stuff filled with your data. 请记住,在应仅执行或求值一次的每个angular指令中都使用一次性绑定运算符'::' ,这意味着如果您不需要监视更改(ng-​​click,ng-class,ng- if,ng-switch ...)以及包含数据的标签,文本,字段和内容。

Doing a ng-repeat with too much angular interaction can create a lot of watchers. 进行过多角度交互的ng-repeat可能会产生大量观察者。 Hence, the perfomance of your app will decrease dramatically. 因此,您的应用程序的性能将大大降低。 Imagine an ng-repeat of a portion of html with 1 ng-click, 1 ng-class and three fields. 想象一下,用1 ng-click,1 ng-class和三个字段对html的一部分进行ng-repeat。 These are 5 watchers, so 5 X 50 rows are 250 watchers ... 这些是5位观察者,因此5 X 50行是250位观察者 ...

Also if your list is not going to change you can use algo :: on the ng-repeat directive. 另外,如果您的列表不会更改,则可以在ng-repeat指令上使用algo :: Example: 例:

<div ng-repeat="item in ::ctrl.items"></div>

代替ng-repeat="item in items" ,对于ionic可以使用collection-repeat="item in items 。这是ng-repeat的真正优化版本,适用于ionic。有关更多信息,请查看此链接: collection-repeat in离子的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM