extjs:从json创建配置块时不会配置,例如选项卡标题
摘自json文件extjs:从json创建配置块时不会配置,例如选项卡标题,extjs,Extjs,摘自json文件 { "items": [ { "xtype": "tabbarcontext", "ptype": "tabbarcontext", "pstype": "maintab", "activeTab": 0, //"title": "NotTitleConfig", "config": [ {"title": "TitleConfig"}
{
"items": [
{
"xtype": "tabbarcontext",
"ptype": "tabbarcontext",
"pstype": "maintab",
"activeTab": 0,
//"title": "NotTitleConfig",
"config": [
{"title": "TitleConfig"}
],
"items": [
{
"xtype": "panel",
"ptype": "tab",
"layout": {
"type": "border"
},
将此json插入视口时
Ext.apply(me, {
// we are adding TabBar with 4 tabs to Viewport
items: appItems // json retrieved from store
选项卡面板已创建,activeTab=0,但config:尚未设置标题。在json文件中注释代码“title”:“NotTitleConfig”会设置选项卡标题。为什么会这样?tia.配置应该是JavaScript对象,而不是JSON字符串。以下几点应该有效
Ext.apply(me, { items: Ext.JSON.decode(appItems) });
谢谢你看这个。上面给出了“解码无效的json字符串”。由于json直接成功加载到Viewport.items中——只是没有应用config:——这个错误让我很惊讶。我正在从appDataStore.proxy.reader.rawData加载json,因为这可以进行w/o转换。。。是否有更好的商店财产可供抢夺?如果您能对以上内容作更多解释,我们将不胜感激。。。。当我将原始数据直接转储到Viewport.item和just config:中时,很难理解为什么所有选项卡、网格、表单和字段都能正确显示,这似乎被忽略了。tia@MicC这差不多就是答案;JSON无效。正如我在上面所写的,apply不能处理JSON字符串,因为它必须是一个对象。这就是它失败的原因。使用ready中的rawData是正确的方法。