[英]Sending 'Authorization' header in Ext JS Ajax Request, Chrome vs. Firefox
[英]Ext JS - Store vs. JsonStore
在比較了兩個類的文檔之后,我很好奇為什么為什么要使用Ext.data.JsonStore而不是其超類Ext.data.Store。 該文檔陳述了有關JsonStore的以下內容:
小型幫助程序類,使從JSON數據創建Ext.data.Stores更加容易。 JsonStore將自動用Ext.data.reader.Json配置。
然后,文檔顯示了JsonStore的典型配置,如下所示:
var store = new Ext.data.JsonStore({
// store configs
autoDestroy: true,
storeId: 'myStore',
proxy: {
type: 'ajax',
url: 'get-images.php',
reader: {
type: 'json',
root: 'images',
idProperty: 'name'
}
},
//alternatively, a Ext.data.Model name can be given (see Ext.data.Store for an example)
fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
});
上面的代碼將閱讀器類型顯式設置為'json'-JsonStore中是否隱含了json類型? 對於我來說,此配置似乎與某人配置代理以讀取Ext.data.Store實例中的JSON文件的方式沒有什么不同。
我是否誤解了Ext.data.JsonStore的使用? 如果沒有,那么使用它而不是Ext.data.Store有什么好處?
謝謝!
看一下Ext.data.JsonStore
的定義:
Ext.define('Ext.data.JsonStore', {
extend: 'Ext.data.Store',
alias: 'store.json',
requires: [
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json',
'Ext.data.writer.Json'
],
constructor: function(config) {
config = Ext.apply({
proxy: {
type : 'ajax',
reader: 'json',
writer: 'json'
}
}, config);
this.callParent([config]);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.