页面的最大可能角度范围

Maximum possible angular scopes for a page

本文关键字:范围      更新时间:2023-09-26

Angular使用3个字母数字字符作为作用域id。例如002,0FG、AAA。。。

这是否意味着一个页面的唯一作用域限制为46656?如果达到该限制,angular是否会增加作用域id中的字符数,或者该页面会发生什么?

在源代码中发现:https://github.com/angular/angular.js/blob/a591e8b8d302efefd67bf0d5c4bad300a5f3aded/src/Angular.js#L296

/**
 * A consistent way of creating unique IDs in angular.
 *
 * Using simple numbers allows us to generate 28.6 million unique ids per second for 10 years before
 * we hit number precision issues in JavaScript.
 *
 * Math.pow(2,53) / 60 / 60 / 24 / 365 / 10 = 28.6M
 *
 * @returns {number} an unique alpha-numeric string
 */
function nextUid() {
  return ++uid;
}

在10年内每秒生成2860万个唯一ID。。。因此9.0252734e+15

创建作用域时在此处引用nextId:https://github.com/angular/angular.js/blob/7c6026437afe2ea4bdf824cbe022d4849264bb70/src/ng/rootScope.js#L208