簡體   English   中英

Uncaught TypeError:extjs4中未定義undefined嗎?

[英]Uncaught TypeError: undefined is not a function in extjs4?

我正在extjs4 MVC中工作,當我使用本地存儲存儲數據時遇到問題,並且我打算將代理類型從ajax動態更改為localStorage。

將數據設置為localstorage后,出現錯誤Uncaught TypeError:undefined不是函數。

我的模特:

Ext.define('Am.model.sn.UserModel',{
    extend: 'Ext.data.Model',
    //idproperty:'userId',//fields property first position pk. 
        fields: ['userId','firstName','middleName','lastName','languageId','primaryEmail','birthDate','password','securityQuestionId','securityQuestionAnswer','isMale','creationTime','ipAddress','confirmationCode','userStatusId']

}); 

我的控制器:

Ext.define('Am.controller.sn.UserController1',
{
    init:function()
    {
        console.log('Initialized Users! This happens before the Application launch function is called'); 
        this.control(
        {
            ...
        });
    },

    remeberMe : function()
    {
        console.log("check box selected");
        var email=this.getUserName().getValue();
        var password=this.getPassword().getValue();
        console.log("email="+email);
        var objCheckBox=Ext.getCmp('checkbox');
        if(objCheckBox.getValue()==true)

        {
            window.localStorage.clear();

            // Here I am getting error Uncaught TypeError: undefined is not a function 
            var lsProxy = new Ext.data.proxy.LocalStorage({
                id: 'localp',
                type:'localstorage',                
            });

            var modelObject = Ext.ModelManager.create(
            {
                primaryEmail:email,
                password: password,
                proxy:lsProxy
            }, 'Balaee.model.sn.UserModel');

            modelObject.setProxy(lsProxy);
            modelObject.save();
        } else {
            console.log("check box is not selected");
        } 
    },
});

請給我建議...

首先,如果我正確理解您的代碼-您正在將用戶及其密碼加載到客戶端。 這是一個巨大的安全風險,因為任何人都可以看到此數據(只需單擊幾下鼠標)。

其次, LocalStorage沒有type配置。

第三,如果您確實在此行(而不是調用堆棧中的某些子行)中收到錯誤:

var lsProxy = new Ext.data.proxy.LocalStorage({

只能是Ext.data.proxy不在范圍內。

嘗試將以下配置添加到您的控制器:

requires: ['Ext.data.proxy.LocalStorage'],

讓我們知道會發生什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM