Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个解决方案,其中我有几个用 ExtJS 制作的屏幕,这些屏幕有按钮和标签,我想将这些字符串移动到常量文件中并在任何地方使用常量。
类似于final Constantsjava 中的类,我们在其中声明常量字符串,然后到处使用它。
final Constants
我执行以下操作
一个。创建一个 js 文件(literals.js),其中包含所有字符串,如下所示
function _literals() { this.Literal1 = "Defining literal"; } var Literals = new _literals();
湾。在 index.html 中添加这个文件 c。在您的 JavaScript 代码中,您可以将文字用作
text: Literals.Literal1