经过大量的谷歌搜索和调试后,我无法弄清楚为什么在我的模型实例中使用 UUID 策略时会出错。
我正在使用 localStorage 在用户设备上存储远程数据,ST2 建议(他们说“你需要”)在我的模型实例中使用 UUID 标识符来生成唯一 ID。
如果我不这样做,我会得到:
[WARN][Anonymous] Your identifier generation strategy for the model does not ensure unique id's. Please use the UUID strategy, or implement your own identifier strategy with the flag isUnique.
如果我这样做,我会得到
Uncaught TypeError: Cannot call method 'substring' of undefined
这是我的模型:
Ext.define("MyApp.model.News", {
extend: 'Ext.data.Model',
config : {
idProperty: "localId",
identifier: {
type: 'uuid'
},
fields : [ {
name: "localId",
type: "auto"
},{
name : "id",
type : "integer"
}, {
name : "title",
type : "string"
}[...]],
proxy: {
type: 'localstorage',
id : 'proxyNews'
}
}
});
和 localStorage 商店:
Ext.define('MyApp.store.NewsLocalStorage', {
extend: "Ext.data.Store",
config: {
storeId: 'newsLocalStorage',
model: "Lmde.model.News",
autoLoad: true
}
});
我错过了什么?