秃头哥陪你练Ext7.0.0之创建工程

一、介绍

Extjs是一个功能非常强大的前端框架, 是浏览器里的桌面级UI库(类似WinformSwing)。作为曾经的企业级开发主流框架, 和目前流行的三大框架(React/Angular/Vue)不同的是, Extjs提供了一整套完整而强大的组件, 开发者可以只使用JavaScript, 也能够迅速的开发出强大美观的软件界面

优点
1.开箱即用
2.节省时间,产品可以尽快上市
3.几乎不用考虑美工css,只需js功底
4.mvc、mvvm设计模式,面向对象编程思想
5.丰富且简洁的官方文档,各种idea的插件支持
6.非全开源,给钱可以维护(上海和北京有办事处)

缺点
1.学习难度太大 ,培训时间过长
2.自定义样式比较难做
3.部分优秀的组件、功能收费
4.框架复杂度高,源码难看懂,遇到问题一卡就是好几天
5.不适合小型项目
6.国内使用人数太少,网上资料太少
7.版本更新太快
找工作的不建议入坑ext,没人要,HR不认识,不知道你说啥

二、安装

官网提供了三种生成Ext项目的方法:

1.npm方法

这种方法需要先去官网注册,获取npm为期30天的仓储使用权限

申请使用ext的表单

按照表单提示填写邮箱信息,过一会sencha会发送邮件到你的邮箱

sencha回复的邮件内容1

以及下载方式和npm的登录用户名和密码

sencha回复的邮件内容2

生成ext项目

Step 1: 登录到邮件回复提供的npm仓储

Use your trial or existing npm credentials to log into the npm repository with the @sencha scope.

npm login --registry=https://npm.sencha.com --scope=@sencha

Note: Your email is used for a username where the @ character switched to '..' two periods, for example name@gmail.com converts to name..gmail.com.

Step 2: 使用npm安装全局的ext-gen 命令

Install the Ext JS app generator CLI command tool ext-gen which will be used to generate the application.

npm install -g @sencha/ext-gen

Step 3: 生成

Generate the Ext JS application using the interactive walkthrough. Use ext-gen app -a to skip the interactive walkthrough.

ext-gen app -i

CLI Walkthrough

是否查看默认的package.json? (y/N)

  If you select `yes`, ext-gen shows all defaults for package.json

Would you like to create a package.json file with defaults? (Y/n)

  This creates a package.json with the defaults

What would you like to name your Ext JS app? (MyApp)

  Type name of your app

What type of Ext JS template do you want? (Use arrow keys)

  ❯ make a selection from a list
    type a folder name

What Ext JS template would you like to use?

    classicdesktop
    classicdesktoplogin
    moderndesktop
    moderndesktopminimal
    universalclassicmodern
  ❯ universalmodern

Would you like to generate the Ext JS npm project with above config now? (Y/n)

  Last question, will output the results. 

Step 4: 使用npm运行新的项目

Start up the newly created application in the default browser with these commands.

  • cd ./<your-app-name>
  • npm start

Step 5: 编码你的项目

生成的项目使用webpack-dev-server. 你的代码变更会直接重新渲染浏览器

  • Modify your source code.
  • Then check the browser, it will auto reload and update with the new changes.

2.CMD方式

首先在sencha 官方下载最新的cmd (CMD7.0地址

注:如果使用7.0以下的CMD是无法生成ext7.0以上的项目的

安装完成cmd 以后执行sencha 命令查看sencha 版本

 >sencha 
 F:\sencha\demo\MobilDemo>sencha
 Sencha Cmd v7.0.0.40
 Sencha Cmd provides several categories of commands and some global switches. In
 most cases, the first step is to generate an application based on a Sencha SDK
 such as Ext JS or Sencha Touch:
 
   sencha -sdk /path/to/sdk generate app MyApp /path/to/myapp

 Sencha Cmd supports Ext JS 4.1.1a and higher and Sencha Touch 2.1 and higher.

 To get help on commands use the help command:

    sencha help generate app

   For more information on using Sencha Cmd, consult the guides found here:

  http://docs.sencha.com/cmd/

在终端中执行>sencha help generate app 会有如下两条提示

F:\sencha\demo\MobilDemo>sencha help generate app
Sencha Cmd v7.0.0.40
sencha generate app

This command generates an empty application given a name and target folder.

The application can be extended using other sencha generate commands (e.g.,
sencha generate model).

Other application actions are provided in the sencha app category (e.g.,
sencha app build).

Sencha Cmd can also automatically download and extract a framework by
specifying the name of the framework as an argument:

    sencha generate app -ext MyAppName ./MyAppPath

This will generate an application using the newest version available
for the specified framework.

For Ext JS 6, by default, this application will be a Universal Application.
To override this and select a particular toolkit, you can use either of
these variations:

    sencha generate app -ext -classic MyAppName ./MyAppPath
    sencha generate app -ext -modern MyAppName ./MyAppPath


Options
  * --controller-name, -c - The name of the default Controller
  * --library, -l - the pre-built library to use (core or all). Default: core
  * --name, -n - The name of the application to generate
  * --path, -p - The path for the generated application
  * --refresh, -r - Set to false to skip the "app refresh" of the generated app
  * --starter, -s - Overrides the default Starter App template directory

按照终端提示执行sencha generate app -ext -classic MyAppName ./MyAppPath创建桌面版的app

按照终端提示执行sencha generate app -ext -modern MyAppName ./MyAppPath创建手机端的app

debug 工程

sencha app watch  //启动sencha 内置的jetty server ,观察代码变化并且重新渲染,此过程或build项目

build工程

cd <你的项目路径>

sencha app build  //build的时候可以加debug参数查看详细的构建日志

三、first blood(Helloword)

因为ext的趋势是在往移动端发展,所以我创建一个移动端的项目
目录结构如下

.sencha/                        # Sencha-specific files (primarily configuration)
    app/                        # Application-specific content
        sencha.cfg              # Application configuration file for Sencha Cmd
        Boot.js                 # Private, low-level dynamic loader for JS and CSS
        Microloader.js          # Loads app based on app.json content
        build-impl.xml          # Standard application build script
        *-impl.xml              # Implementations of various build phases
        defaults.properties     # Default values and docs for build properties
        ext.properties          # Build property values specific to Ext JS
        *.defaults.properties   # Build properties by environment (e.g. "testing")
        plugin.xml              # Application-level plugin for Sencha Cmd
        codegen.json            # Data for merging generated code during upgrade
    workspace/                  # Workspace-specific content (see below)
        sencha.cfg              # Workspace configuration file for Sencha Cmd
        plugin.xml              # Workspace-level plugin for Sencha Cmd

ext/                            # A copy of the Ext JS SDK
    cmd/                        # Framework-specific content for Sencha Cmd
        sencha.cfg              # Framework configuration file for Sencha Cmd
    classic/                    # Packages related to the Classic Toolkit
        classic/                # Ext JS Classic Toolkit package
        theme-neptune/          # Classic Toolkit Theme Package for Neptune
        theme-triton/           # Classic Toolkit Theme Package for Triton
        ...
    modern/                     # Packages related to the Modern Toolkit
        modern/                 # Ext JS Modern Toolkit package
        theme-neptune/          # Modern Toolkit Theme Package for Neptune
        theme-triton/           # Modern Toolkit Theme Package for Triton
        ...
    packages/                   # Framework supplied packages
        charts/                 # Charts package
        ux/                     # Contents of "Ext.ux" namespace
    ...

index.html                      # The entry point to your application
app.json                        # Application manifest
app.js                          # Launches the Application class
app/                            # Your application's source code in MVC structure
    model/                      # Folder for application model classes
    store/                      # Folder for application stores
    view/                       # Folder for application view classes
        main/                   # Folder for the classes implementing the Main View
            Main.js             # The Main View
            MainModel.js        # The `Ext.app.ViewModel` for the Main View
            MainController.js   # The `Ext.app.ViewController` for the Main View
    Application.js              # The `Ext.app.Application` class

packages/                       # Sencha Cmd packages
workspace.json                  # Workspace JSON descriptor

build/                          # The folder where build output is placed

执行sencha app watch


谷歌爸爸手机模式调试图
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,242评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,769评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,484评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,133评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,007评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,080评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,496评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,190评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,464评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,549评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,330评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,205评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,567评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,889评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,160评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,475评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,650评论 2 335

推荐阅读更多精彩内容