- Sencha Touch 教程
- Sencha Touch - 首页
- Sencha Touch - 概述
- Sencha Touch - 环境
- Sencha Touch - 命名约定
- Sencha Touch - 架构
- Sencha Touch - MVC 解释
- Sencha Touch - 第一个应用程序
- Sencha Touch - 构建应用程序
- Sencha Touch - 迁移步骤
- Sencha Touch - 核心概念
- Sencha Touch - 数据
- Sencha Touch - 主题
- Sencha Touch - 设备配置文件
- Sencha Touch - 依赖项
- 环境检测
- Sencha Touch - 事件
- Sencha Touch - 布局
- Sencha Touch - 历史和支持
- Sencha Touch - 上传和下载
- Sencha Touch - 查看组件
- Sencha Touch - 封装
- Sencha Touch - 最佳实践
- Sencha Touch 有用资源
- Sencha Touch - 快速指南
- Sencha Touch - 有用资源
- Sencha Touch - 讨论
Sencha Touch - 类系统
Sencha Touch 是一个具有面向对象编程功能的 JavaScript 框架。Sencha Touch 类系统基于 Ext JS 4 标准。Ext 是封装了 Sencha Touch 中所有类的命名空间。
在 Sencha Touch 中定义一个类
Ext 提供了 300 多个类,我们可以将其用于各种功能。
Ext.define() 用于在 Sencha Touch 中定义类。
语法
Ext.define(class name, class members/properties, callback function);
类名根据应用程序结构是类的名称。例如,appName.folderName.ClassName studentApp.view.StudentView。
类属性/成员定义类的行为。
回调函数是可选的。当类已正确加载时,将调用该函数。
Sencha Touch 类定义示例
Ext.define(studentApp.view.StudentDeatilsGrid, {
name: 'StudentName,
read: function(bookName){
console.log(this.name +’is reading ’bookName);
}
});
创建对象
与其他基于 OOP 的语言一样,我们也可以在 Sencha Touch 中创建对象。
在 Sencha Touch 中使用 new 关键字创建对象的方法 -
var studentObject = new student(); studentObject.read(‘History’);
控制台输出将为 StudentName 正在读取历史记录。
sencha_touch_core_concepts.htm
广告