matrix1984 2009-07-14 17:32
浏览 269
已采纳

EXT:关于TreePanel中json数据的格式问题

loader: new Ext.tree.TreeLoader({
dataUrl:'test.json'
}),

test.json为如下时正常:
[
{id:'01',text:'01',children:[
{id:'01-01',text:'01-01',leaf:true},
{id:'01-02',text:'01-02',children:[
{id:'01-02-01',text:'01-02-01',leaf:true},
{id:'01-02-02',text:'01-02-02',leaf:true}
]},
{id:'01-03',text:'01-03',leaf:true}
]},
{id:'02',text:'02',leaf:true}
]

如果在每个元素都加上属性url='',就不行了,如下:
[
{id:'01',url='',text:'01',children:[
{id:'01-01',url='',text:'01-01',leaf:true},
{id:'01-02',url='',text:'01-02',children:[
{id:'01-02-01',url='',text:'01-02-01',leaf:true},
{id:'01-02-02',url='',text:'01-02-02',leaf:true}
]},
{id:'01-03',url='',text:'01-03',leaf:true}
]},
{id:'02',url='',text:'02',leaf:true}
]

请问是什么问题呢?

[b]问题补充:[/b]
多谢啊,好郁闷啊,我以为在哪里出错了,原来是格式不对,多谢了。

  • 写回答

1条回答 默认 最新

  • iteye_20589 2009-07-14 17:41
    关注

    [quote]如果在每个元素都加上属性url='',就不行了,如下:
    [
    {id:'01',url='',text:'01',children:[
    {id:'01-01',url='',text:'01-01',leaf:true},
    {id:'01-02',url='',text:'01-02',children:[
    {id:'01-02-01',url='',text:'01-02-01',leaf:true},
    {id:'01-02-02',url='',text:'01-02-02',leaf:true}
    ]},
    {id:'01-03',url='',text:'01-03',leaf:true}
    ]},
    {id:'02',url='',text:'02',leaf:true}
    ] [/quote]

    因为是[color=red]JSON格式[/color]要符合key value形式,只能写成[color=red]key:value[/color],所以你那么写就不对了....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具