【工作笔记】从零开始学ExtJs6(二)——登录模块
来源:互联网 发布:unity3d塔防游戏 编辑:程序博客网 时间:2024/05/19 21:44
题外话
上章,已经有一个项目框架了。大概是这个样子
- app/store : stores文件
- app/model : models文件
- classic 桌面端文件 modern 手机端文件
- classic/view: viewController viewModel以及view文件
- override:重写组件
- sass:全局样式
- app.js : 入口
- app.json : 文件属性配置
- application.js 启动加载
登录模块的实现
文件结构如下
① 注释掉app.js中的mainview
//mainView: 'report.view.main.Main'
② Application.js中增加
views: [ 'report.view.login.LoginForm', 'report.view.main.Main'],launch: function () { // It's important to note that this type of application could use // any type of storage, i.e., Cookies, LocalStorage, etc. var loggedIn; // Check to see the current value of the localStorage key loggedIn = localStorage.getItem("isLogin"); // This ternary operator determines the value of the TutorialLoggedIn key. // If TutorialLoggedIn isn't true, we display the login window, // otherwise, we display the main view Ext.create({ xtype: loggedIn ? 'app-main' : 'login' }); },
③ LoginForm.js 内容
Ext.define('report.view.login.LoginForm', { requires: ['report.controller.login.LoginController','Ext.form.Panel'], //处理登录事件 extend: 'Ext.window.Window', //登录窗体 xtype: 'login', controller: 'login', //设置控制器(别名alias) //True to make the floated component modal and mask everything behind it when displayed, // false to display it without restricting access to other UI elements. //draggable: false, 不可拖放 title: 'XX报表系统', closable: false, //不可关闭 resizable: false, //不可伸缩 autoShow: true,//自动显示 modal: true, //隐藏其他组件 //glyph: 'xf007@FontAwesome', //字体 //容器中需要存放的元素:可以是表单,也可以是面板,表格等 items: [{ xtype: 'form',//xtype 容器类型 form 表单类型 //Specifies a name for this component inside its component hierarchy //(This name must be unique within its view or its Ext.app.ViewCont...) reference: 'form', //指定组件层级 bodyPadding: 20, //行边距 items: [{ //<label for="用户名" width="50"></label> //<input type="text" name="userName" placeholder="用户名"/> xtype: 'textfield', name: 'userName', labelWidth: 50, fieldLabel: '用户名', allowBlank: false, emptyText: '请输入员工账号' }, { xtype: 'textfield', name: 'password', labelWidth: 50, inputType: 'password', fieldLabel: '密 码', allowBlank: false, emptyText: '请输入员工密码', enableKeyEvents: true, //触发事件(如果为false,不能点击任何事件) 与listeners对应 scope:this,//default scope (this pointer) listeners:{ //监听回车 specialkey:function(field,e){ if (e.getKey()==Ext.EventObject.ENTER){ //up 得到dom(window) //lookupReference 得到component的引用 //触发自定义事件 this.up('window').lookupReference('loginbutton').fireEvent('click'); //this.up('window').lookupReference('loginbutton').click(); } } } }] }], buttons: [{ name: 'loginbutton', text: '登 录', glyph: 'xf110@FontAwesome', region: 'center', reference:'loginbutton',//通过lookupReference找到 listeners: { //监听事件 click: 'onLoginClick'//单击事件 调用LoginConroller.js中的onLoginbtnClick函数 } }, { name: 'registbutton', text: '重 置', glyph: 'xf118@FontAwesome', listeners: { click: 'onRest'//单击事件 调用LoginConroller.js中的onLoginbtnClick函数 } }]});
④ LoginController.js
Ext.define("report.controller.login.LoginController",{ extend: 'Ext.app.ViewController', alias: 'controller.login', onLoginClick: function() { // This would be the ideal location to verify the user's credentials via // a server-side lookup. We'll just move forward for the sake of this example. // Set the localStorage value to true localStorage.setItem("isLogin", true); // Remove Login Window this.getView().destroy(); // Add the main view to the viewport Ext.create({ xtype: 'app-main' }); }})
3 0
- 【工作笔记】从零开始学ExtJs6(二)——登录模块
- 【工作笔记】从零开始学ExtJs6(二)——登录模块
- 【工作笔记】从零开始学ExtJs6(一)——构建项目
- 【工作笔记】从零开始学ExtJs6(三)—— 首页搭建
- 【工作笔记】从零开始学ExtJs6(四)—— 常用api小记
- 【工作笔记】从零开始学ExtJs6(一)——构建项目
- 【工作笔记】从零开始学ExtJs6(三)—— 首页搭建
- 【工作笔记】从零开始学ExtJs6( 四)—— 首页树状菜单和Tab页的实现
- 【工作笔记】从零开始学ExtJs6( 四)—— 首页树状菜单和Tab页的实现
- 【工作笔记】ElasticSearch从零开始学(二)—— 入门(搜索)
- 【工作笔记】ElasticSearch从零开始学(一)—— 介绍
- 【工作笔记】ElasticSearch从零开始学(五)—— Java_SearchAPI
- 【工作笔记】ElasticSearch从零开始学(六)—— JavaAPI_Aggregation
- 【工作笔记】从零开始学ElasticSearch( 七)—— 集群
- 【工作笔记】ElasticSearch从零开始学(三)—— 入门(聚合)
- 【工作笔记】从零开始学ElasticSearch( 八)—— 数据(CRUD语法)
- 【工作笔记】从零开始学ElasticSearch( 十)—— 高级扩展:搜索(Basic)
- 【工作笔记】ElasticSearch从零开始学(四)—— Java_DocumentAPI(CRUD)
- 面试问题
- Minimum Absolute Difference in BST
- Base class does not contain a constructor that takes '0' argument
- CAReplicatorLayer的使用示例
- 阿里云RDS调用存储过程报错ERR1449
- 【工作笔记】从零开始学ExtJs6(二)——登录模块
- Eclipse安装server插件
- c# 获取路径
- angular ui-grid之过滤器设置
- TCP、UDP
- WinDbg-如何抓取dump文件
- struts2+ajax 传输用户自定义的对象,而非字符串
- cesium学习笔记之五——Linux下部署cesium项目
- js空串判断