luoyifan 4 years ago
parent
commit
59c8d28341
2 changed files with 21 additions and 15 deletions
  1. 19 0
      src/controls/textfield.js
  2. 2 15
      src/init.ts

+ 19 - 0
src/controls/textfield.js

@@ -0,0 +1,19 @@
+import _ from 'lodash'
+import $ from 'jquery'
+
+export default function () {
+    /**
+     * 改变必填项之前加星号
+     */
+    const t1 = Ext.form.field.Text.prototype.initComponent
+    Ext.form.field.Text.override({
+        initComponent: function () {
+            if (this.allowBlank === false || this.validateBlank === true) {
+                this.beforeLabelTextTpl = [
+                    '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
+                ];
+            }
+            t1.call(this)
+        }
+    });
+}

+ 2 - 15
src/init.ts

@@ -1,5 +1,6 @@
 import _ from 'lodash'
 import initMainTab from './controls/MainTab'
+import initTextfield from './controls/textfield'
 
 export function init() {
     // 引入 filters 过滤插件
@@ -49,20 +50,6 @@ export function init() {
         _doAddListener.call(this, ename, fn, scope, options, order, caller, manager)
     }
 
-    /**
-     * 改变必填项之前加星号
-     */
-    const t1 = Ext.form.field.Text.prototype.initComponent
-    Ext.form.field.Text.override({
-        initComponent: function () {
-            if (this.allowBlank === false || this.validateBlank === true) {
-                this.beforeLabelTextTpl = [
-                    '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
-                ];
-            }
-            t1.call(this)
-        }
-    });
-
     initMainTab()
+    initTextfield()
 }