如何更新 extJs 中的存储(出现 404 错误)?

How to update store in extJs (it falls with 404 error)?

我是 ExtJs 的新手,遇到了一些问题。 这是我的模型:

Ext.define('MyTestApp.model.Product', {
extend: 'Ext.data.Model',

fields: [
    {name: 'id',  type: 'int'},
    {name: 'name',  type: 'string'},
    {name: 'description',  type: 'string'},
    {name: 'price',  type: 'float'},
    {name: 'count',  type: 'int'}
],});

这是商店:

Ext.define('MyTestApp.store.Products', {
extend: 'Ext.data.Store',
alias: 'store.products',
storeId: 'products',

model: 'MyTestApp.model.Product',

data: [
    {id: 1, name: 'Notebook Lenovo', description: 'Ноутбук Lenovo IdeaPad 330-15IKB', price: 100, count: 2},
    {id: 2, name: 'Logitech Keyboard', description: 'Клавиатура Logitech Comfort K280E', price: 50, count: 9},
    {id: 3, name: 'Logitech Mouse', description: 'Мышь Logitech M90', price: 25, count: 0},
    {id: 4, name: 'Gaming mouse pad', description: 'Коврик для мыши A4Tech X7-200MP', price: 150, count: 5},
    {id: 5, name: 'Samsung smartphone', description: 'Смартфон Samsung Galaxy A51 64GB', price: 122, count: 3},
    {id: 6, name: 'Protective glass', description: 'Защитное стекло Samsung InterStep FSC', price: 10, count: 33},
],});

我想add/update商店中的一些记录,但是store.load()或newModelInstance.save()等方法不起作用。控制台错误: POST http://localhost:1841/MyTestApp.model.Product?_dc=1596285700466 404(未找到)

要将新记录添加到存储中,您可以使用 store.add({id:123, name: “some name”...}) 方法。要更新记录,例如 strore.findRecord(),然后更新商店中找到的记录,即 record.set(fieldName, fieldValue)。 要更新服务器上的 store/records 数据(提交),您必须为 store/record.

配置代理