- Ext.js 教程
- Ext.js - 首页
- Ext.js - 概述
- Ext.js - 环境设置
- Ext.js - 命名规范
- Ext.js - 架构
- Ext.js - 第一个程序
- Ext.js - 类系统
- Ext.js - 容器
- Ext.js - 布局
- Ext.js - 组件
- Ext.js - 拖放
- Ext.js - 主题
- Ext.js - 自定义事件和监听器
- Ext.js - 数据
- Ext.js - 字体
- Ext.js - 样式
- Ext.js - 绘制
- Ext.js - 本地化
- Ext.js - 可访问性
- Ext.js - 调试代码
- Ext.js - 方法
- Ext.js 有用资源
- Ext.js - 问题和解答
- Ext.js - 快速指南
- Ext.js - 有用资源
- Ext.js - 讨论
Ext.js - 方法
以下是几个在 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.iPhone 如果使用的是 iPhone,则此函数将返回 true,否则返回 false。 |
| 6 | Ext.is.iPod 如果使用的是 iPod,则此函数将返回 true,否则返回 false。 |
| 7 | Ext.is.iPad 如果使用的是 iPad,则此函数将返回 true,否则返回 false。 |
| 8 | Ext.is.Windows 如果使用的是 Windows 操作系统,则此函数将返回 true,否则返回 false。 |
| 9 | Ext.is.Linux 如果使用的是 Linux 操作系统,则此函数将返回 true,否则返回 false。 |
| 10 | Ext.is.Blackberry 如果使用的是 Blackberry,则此函数将返回 true,否则返回 false。 |
| 11 | Ext.is.Mac 如果使用的是 Mac 操作系统,则此函数将返回 true,否则返回 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 功能画布绘制方法。在内部,它检查 doc.createElement('canvas').getContext 并根据此方法的输出返回值。 |
| 5 | Ext.supports.Range 它检查浏览器是否支持 document.createRange 方法。 |
Ext.String 类
Ext.String 类具有各种用于处理字符串数据的方法。最常用的方法是编码解码、修剪、切换、urlAppend 等。
编码解码函数 - 这些是 Ext.String 类中可用于编码和解码 HTML 值的函数。
| 序号 | 方法和描述 |
|---|---|
| 1 | Ext.String.htmlEncode 此函数用于编码 html 值以使其可解析。 示例 - Ext.String.htmlEncode("< p > Hello World < /p >");
Output - "< p > Hello World < /p >".
|
| 2 | Ext.String.htmlDecode 此函数用于解码已编码的 html 值。 示例 - Ext.String.htmlDecode("< p > Hello World < /p >");
Output - "< p > Hello World < /p >"
|
| 3 | Ext.String.trim 此函数用于修剪字符串中不需要的空格。 Ext.String.trim(' hello ');
Output – "hello"
|
| 4 | Ext.String.urlAppend 此方法用于在 URL 字符串中追加值。 示例 - Ext.String.urlAppend('https://www.google.com' , 'hello');
Output - "https://www.google.com?hello"
Ext.String.urlAppend('https://www.google.com?index=1' , 'hello');
Output – "https://www.google.com?index=1&hello"
|
| 5 | Ext.String.toggle 此函数用于在两个不同的值之间切换值。 示例 - var toggleString = 'ASC' toggleString = Ext.String.toggle(a, 'ASC', 'DESC'); Output – DESC as toggleString had value ASC. Now again, if we print the same we will get toggleString = “ASC” this time, as it had value 'DESC'. It is similar to ternary operator 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 | 版本相关函数 如果该函数与 IE 相关联,则此函数将返回当前正在使用的浏览器的版本。在 Firefox 浏览器中,它返回 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() 此函数返回变量的数据类型。 示例 - var a = 5; var b = 'hello'; Ext.typeOf(a); Output – Number Ext.typeOf(b); Output - String |
||||||||||||||
| 6 | 数据类型相关方法 - 这些函数根据变量的数据类型返回布尔值 示例 - var a = ['a', 'bc'];
var b = 'hello';
var c = 123;
var emptyVariable;
var definedVariable;
function extraFunction(){return true;}
|