javascript - JS 控制台错误显示 Extjs 尝试对类发出 GET 请求,就好像它是一个文件一样

标签 javascript extjs extjs6

抱歉,如果标题不是最好的。

我正在 Extjs 6 中草拟一个测试项目。我有一个 View 模型类,它使用名为 customers 的商店:

Ext.define('ChildSessionBinding.view.main.ChildSessionModel',{
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.binding.childsession',

    requires:[
        'Ext.data.Store',
        'ChildSessionBinding.model.Customer'
    ],

    stores:{
        customers:{
            model: 'ChildSessionBinding.model.Customer',
            autoLoad: true,
            session: true
        }
    }
});

它需要的模型中有硬编码的测试数据:

Ext.define('ChildSessionBinding.model.Customer', {
    extend: 'Ext.data.Model',

    fields: [
        { name: 'name', type: 'auto' },
        { name: 'phone', type: 'auto' }
    ],

    data:[
        {name: 'test', phone: '12345'}
    ]
});

使用 ViewModel 的 View 只是一个显示简单网格的面板:

Ext.define('ChildSessionBinding.view.main.ChildSession', {
    extend: 'Ext.panel.Panel',

    xtype: 'binding-child-session',

    title: 'Binding Child Session Demo',
    layout: {
        type: 'vbox',
        align: 'stretch'
    },

    viewModel: {
        type: 'binding.childsession'
    },

    controller: 'binding.childsession',

    session: true,

    items:[
        {
            flex: 1,
            xtype: 'grid',
            bind: '{customers}',
            columns:[
                {
                    dataIndex: 'name',
                    flex: 1,
                    text: 'Name'
                },
                {
                    dataIndex: 'phone',
                    flex: 1,
                    text: 'Phone'
                },
                {
                    xtype: 'widgetcolumn',
                    width: 90,
                    widget: {
                        xtype: 'button',
                        text: 'Edit',
                        handler: 'onEditCustomerClick'
                    }
                }
            ]
        }
    ]
});

当我在浏览器中加载它时,网格不会加载。我打开了 javascript 控制台,发现它正在尝试使用模型的完全限定名称向服务器发出 get 请求:

wtf

我将其与 the kitchen sink example I'm trying to duplicate 进行了比较以及我在其他项目中创建的其他 View 模型商店,我没有看到任何会导致这种情况的情况。

此外,为了排除任何项目文件结构问题,这里是文件夹/文件结构:

folder and file structure

编辑

这是来自 JavaScript 控制台的堆栈跟踪:

the javascript console stack trace

有人发现问题了吗?

最佳答案

将数据放入您的商店中,而不是模型中。模型没有 data property .

关于javascript - JS 控制台错误显示 Extjs 尝试对类发出 GET 请求,就好像它是一个文件一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32253987/

相关文章:

javascript - 检查 Angular HTML 中的 bool 真值

ExtJs - 通过 Gridpanel 的索引获取行

javascript - 堆栈 ExtJS 6 + Spring Boot

javascript - ItemTpl onclick函数调用extjs 6

javascript - 从 JSON 中抓取树

javascript - 从 d3 获取图案并将其设置为 div 的边框

javascript - 带 form_tag 的动态选择菜单

javascript - 在 HTML 中调用 javascript 函数

javascript - 如何使文本字段坚持其在 extjs 中的标签?

javascript - 如何为 ExtJS 对象创建动态变量名?