AI教程网 - 未来以来,拥抱AI;新手入门,从AI教程网开始......

Ext.js 方法

Ext.js教程 AI君 52℃

下面是几个内置函数,主要在Ext JS中使用:

Ext.is类:

此类检查您使用的平台,无论是手机还是桌面,Mac或Windows操作系统。
这些是与Ext.is类相关的以下方法

编号 方法和描述
1

Ext.is.Platforms

此函数返回此版本可用的平台。

例如。 当你运行下面的函数,它返回如下:

[Object { property="platform", regex=RegExp, identity="iPhone"}, Object { property="platform", regex=RegExp, identity="iPod"}, Object { property="userAgent", regex=RegExp, identity="iPad"}, Object { property="userAgent", regex=RegExp, identity="Blackberry"}, Object { property="userAgent", regex=RegExp, identity="Android"}, Object { property="platform", regex=RegExp, identity="Mac"}, Object { property="platform", regex=RegExp, identity="Windows"}, Object { property="platform", regex=RegExp, identity="Linux"}]
2

Ext.is.Android

如果你使用Android操作系统,这个函数将返回true,否则返回false。

3

Ext.is.Desktop

如果您正在为应用程序使用桌面,则此函数将返回true,否则返回false。

4

Ext.is.Phone

这个函数将返回true,如果你使用的是移动,否则返回false。

5

Ext.is.Phone

这个函数将返回true如果你使用iPhone的else它返回false。

6

Ext.is.Pod

如果你使用iPod,这个函数将返回true否则返回false。

7

Ext.is.iPad

这个函数将返回true如果你使用iPad的else返回false。

8

Ext.is.Windows

这个函数将返回true,如果你使用windows操作系统,否则返回false。

9

Ext.is.Linux

这个函数将返回true,如果你使用的是linux操作系统,否则返回false。

10

Ext.is.Blackberry

如果你使用Blackberry,这个函数将返回true,否则返回false。

11

Ext.is.Mac

这个函数将返回true,如果你使用的是mac操作系统,否则返回false。

Ext.supports类:

因为名称表示这个类提供关于浏览器/设备支持的功能的信息,基本上是当前环境。

编号 方法和描述
1

Ext.supports.History

这返回基于布尔值的设备支持HTML 5历史作为window.history或不支持。 如果设备支持历史记录,那么它返回true否则为false。

2

Ext.supports.GeoLocation

这返回基于布尔值的设备是否支持地理定位方法。 在内部它检查navigator.geolocation方法。

3

Ext.supports.Svg

这返回了基于布尔值的设备是否支持HTML 5功能可缩放矢量图形(SVG)方法。 在内部它检查doc.createElementNS&& !! doc.createElementNS(“http:/”+“/www.w3.org/2000/svg”,“svg”)。createSVGRect。

4

Ext.supports.Canvas

这个返回的布尔值基于设备支持的HTML 5功能canvas是否绘制方法。 在内部它检查doc.createElement(\’canvas\’)。getContext并基于此方法的输出返回值。

5

Ext.supports.Range

这个返回的布尔值是基于浏览器支持的document.createRange方法还是不行。

Ext.String类:

Ext.String类有各种方法处理字符串数据,最常用的方法是编码解码,修剪,切换,urlAppend eyc。

编码解码函数:这些是Ext.String类中可用的函数,用于编码和解码HTML值。

编号 方法和描述
1

Ext.String.htmlEncode

此函数用于编码html值以使其可解析。

 
E.g. Ext.String.htmlEncode("< p > Hello World < /p >"); 
Output - "&lt; p &gt; Hello World &lt; /p &gt;".
2

Ext.String.htmlDecode

此函数用于解码编码的html值

                 
E.g. Ext.String.htmlDecode("&lt; p &gt; Hello World &lt; /p &gt;");
Output -  "< p > Hello World < /p &gt"
3

Ext.String.trim

此函数用于删除字符串中不需要的空格。

例如。 Ext.String.trim(\’hello\’);

输出 – “hello”

4

Ext.String.urlAppend

此方法用于在URL字符串中附加值

例如。 Ext.String.urlAppend(\’https://www.google.com\’,\’hello\’);

输出 – “https://www.google.com?hello”

Ext.String.urlAppend(\’https://www.google.com?index=1\’,\’hello\’);

输出 – “https://www.google.com?index=1&hello”

5

Ext.String.toggle

此函数用于在两个不同的值之间切换值。

例如。 var toggleString =\’ASC\’

toggleString = Ext.String.toggle(a,\’ASC\’,\’DESC\’);

输出 – DESC作为toggleString具有值ASC。 现在再次如果我们打印相同,我们将获得toggleString =“ASC”这一次,因为它的值\’DESC\’。

它类似于三元运算符

toggleString =((toggleString ==\’ASC\’)?\’DESC\’:\’ASC\’);

其他方法

编号 方法和描述
1

Ext.userAgent()

此函数提供有关浏览器userAgent的信息。 UserAgent用于标识Web服务器的浏览器和操作系统。

例如。 如果你在Mozilla工作,它会返回一些东西像:“mozilla / 5.0(windows nt 6.1; wow64; rv:43.0)gecko / 20100101 firefox / 43.0″

2

版本相关功能

这些函数返回当前正在使用的浏览器的版本,如果在firefox浏览器中调用IE相关的函数,则返回0.这些函数是Ext.firefoxVersion,Ext.ieVersion等。

例如。 如果我们使用firefox浏览器,我们调用方法Ext.ieVersion获取版本的IE,那么它返回0或者如果我们在IE浏览器中使用相同的方法,那么它将返回我们使用的版本,如8,9等。

3

Ext.getVersion()

此函数返回当前使用的Ext JS版本。

例如。 如果我们调用Ext.getVersion(),它返回一个值的数组,如版本,短版本等。

Ext.getVersion()。version返回程序中使用的Ext JS的当前版本,例如“4.2.2″。

4

浏览器相关功能

这些函数根据使用的浏览器返回布尔值。 这个方法是Ext.isIE,Ext.isIE6,Ext.isFF06,Ext.isChrome。

例如。 如果我们使用Chrome浏览器,那么Ext.isChrome函数将返回true,其他的都会返回false。

5

Ext.typeOf()

此函数返回变量的数据类型,例如

E.g. var a = 5;  
   var b  = 'hello';
   Ext.typeOf(a);
   Output  Number
   Ext.typeOf(b);
   Output - String
6

DataType相关方法:这些函数根据变量的数据类型返回布尔值。

E.g. var a = ['a', 'bc'];
   var b = 'hello';
   var c = 123;
   var emptyVariable;
   var definedVariable;
   function extraFunction(){return true;}
Ext.isArray(a); //返回true
Ext.isString(b); // return true
Ext.isNumber(c); // return true
Ext.isEmpty(emptyVariable); // return true
Ext.isEmpty(b); // return false
Ext.isDefined(definedVariable); // return true
Ext.isfunction(extraFunction); // return true

转载请注明:www.ainoob.cn » Ext.js 方法

喜欢 (0)or分享 (0)