我是 sencha 的新手,我创建了一个 Login.js。但是我有个问题不知道如何保存数据以及 Sencha Touch 兼容哪个数据库。请有人帮助我如何存储,模型和控制器。
登录.js
Ext.define('RealApp.view.Login', {
extend: 'Ext.form.Panel',
alias: "widget.loginview",
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label'],
config: {
title: 'Login',
scrollable: false,
items: [
{
xtype: "toolbar",
docked: "top",
title: "Login",
items: [
{
xtype: "button",
ui: "back",
text: "Home",
itemId: "backButton",
width: 120,
height: 25
},
{ xtype: "spacer" },
{
xtype: "button",
ui: "action",
text: "Sign Up",
itemId: "signupButton",
width: 120,
height: 25
}
]
},
{
xtype: 'label',
html: 'Login failed. Please enter the correct credentials.',
itemId: 'signInFailedLabel',
hidden: true,
hideAnimation: 'fadeOut',
showAnimation: 'fadeIn',
style: 'color:#990000;margin:5px 0px;'
},
{
xtype: 'fieldset',
title: 'Login',
items: [
{
xtype: 'textfield',
store: "Login",
placeHolder: 'Username',
itemId: 'userNameTextField',
name: 'userNameTextField',
required: true,
itemTpl: "{username}"
},
{
xtype: 'passwordfield',
store: "Login",
placeHolder: 'Password',
itemId: 'passwordTextField',
name: 'passwordTextField',
required: true,
itemTpl: "{password}"
}
]
},
{
xtype: "toolbar",
docked: "bottom",
layout: {
pack: 'center'
},
items: [
{
xtype: 'button',
itemId: 'loginButton',
ui: 'action',
text: 'Log In',
width: 120,
height: 25
}
]
}
],
listeners: [{
delegate: '#loginButton',
event: 'tap',
fn: 'onLogInButtonTap'
},
{
delegate: "#backButton",
event: "tap",
fn: "onBackButtonTap"
},
{
delegate: "#signupButton",
event: "tap",
fn: "onSignUpButtonTap"
}]
},
onLogInButtonTap: function () {
console.log("goLogCommand");
this.fireEvent("goLogCommand", this);
},
onSignUpButtonTap: function () {
console.log("signUpCommand");
this.fireEvent("signUpCommand", this);
},
onBackButtonTap: function () {
console.log("backToHomeCommand");
this.fireEvent("backToHomeCommand", this);
}});
注册.js
Ext.define('RealApp.view.Register', {
extend: 'Ext.form.Panel',
alias: "widget.registerview",
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label', 'Ext.util.DelayedTask'],
config: {
title: 'Register',
scrollable: false,
items: [
{
xtype: "toolbar",
docked: "top",
title: "Register",
items: [
{
xtype: "button",
ui: "back",
text: "Back",
itemId: "backButton",
width: 120,
height: 25
}
]
},
{
xtype: 'fieldset',
title: 'Register',
items: [
{
xtype: 'textfield',
label: 'Username',
store: "login",
itemId: 'userNameTextField',
name: 'userNameTextField',
required: true,
},
{
xtype: 'passwordfield',
label: 'Password',
store: "login",
itemId: 'passwordTextField',
name: 'passwordTextField',
required: true,
}
]
},
{
xtype: "toolbar",
docked: "bottom",
layout: {
pack: 'center'
},
items: [
{
xtype: "button",
ui: "action",
text: "Register",
itemId: "registerButton",
width: 120,
height: 25
}
]
}
],
listeners: [{
delegate: '#registerButton',
event: 'tap',
fn: 'onRegisterButtonTap'
},
{
delegate: "#backButton",
event: "tap",
fn: "onBackButtonTap"
}]
},
onRegisterButtonTap: function () {
console.log("registerCommand");
this.fireEvent("registerCommand", this);
},
onBackButtonTap: function () {
console.log("backCommand");
this.fireEvent("backCommand", this);
}});