console.log无法在JS文件中运行

时间:2016-11-08 21:12:12

标签: javascript extjs syntax

我正在尝试在较大的项目中调试JavaScript文件,并且出于某种原因,console.log()没有向控制台视图输出任何内容。我也尝试过其他功能,例如alert(),但他们也给了我相同的结果。

这是我的代码:

Ext.define('chefRoleSetupFormPanel', {
    extend: 'Ext.form.Panel',

    id: 'chefRoleSetupFormPanel',

    title: 'Role Information',
    url: 'chefCreateRole.php',
    bodyPadding: 10,
    items: [{
        xtype: 'textfield',
        name: 'roleName',
        fieldLabel: 'Name',
        allowBlank: false,
        anchor: '100%'
    }, {
        xtype: 'textareafield',
        grow: true,
        name: 'roleDescription',
        fieldLabel: 'Description',
        anchor: "100% 75%"
    }],
    buttons: [{
        text: 'Reset',
        handler: function() {
            this.up('form').getForm().reset();
        }
    }, {
        text: 'Submit',
        formBind: true, //only enabled once the form is valid
        disabled: true,
        handler: function() {
            var form = this.up('form').getForm();
            if (form.isValid()) {
                form.submit({
                    success: function(form, action) {
                        var roleSetupForm = Ext.getCmp('chefRoleSetupFormPanel');
                        roleSetupForm = roleSetupForm.getForm();

                        var roleName = roleSetupForm.findField('roleName')['value'];
                        var roleDescription = roleSetupForm('roleDescription')['value'];

                        var chefRequiredCookbooksGrid = Ext.getCmp('chefRequiredCookbooksGrid');
                        var runList = chefRequiredCookbooksGrid.getStore().getRange();  

                        console.log(runList);


                        roleSetupForm.submit({
                            params: {
                                roleName: roleName,
                                roleDescription: roleDescription,
                                runList: JSON.stringify(runList)
                            }
                        })
                    },
                    failure: function(form, action) {

                    }
                });
            }
        }
    }]
});

关于为什么会发生这种情况的任何想法?

由于

2 个答案:

答案 0 :(得分:1)

尝试登录失败。你可能有一个错误,你没有抓住。

答案 1 :(得分:1)

console.log()很棒,但我建议使用Ext.log(...)。

这只是我建议遵循的最佳做法。

用法:

Ext.log({level:'debug'}, 'Message Here');