ExtJs 专题
专题目录
您的位置:JS框架 > ExtJs 专题 > Ext.js 方法
Ext.js 方法
作者:--    发布时间:2019-11-20

下面是几个内置函数,主要在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
网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册