标签:san person 引入 bbb 个数 背景 rip pre asc
在html文件中就可以,不用引入其他的链接,直接就能用:下面是案例1-5,想练习哪个把哪个注释去掉就可以,
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>json01</title> </head> <body> <ul> <li id="bj" name="bj">背景</li> </ul> </body> <script type="text/javascript"> // 案例一:对象格式 /* var person = {"firstname":"zhangsan","lastname":"sanfang","age":"100"}; alert(person.lastname); alert(person.age) */ //------------------- //案例二: 数组集合格式 /* var person = [ {"name":"zhangsan","age":"26"}, {"name":"lisi","age":"28"}, {"name":"wangwu","age":"29"} ] alert(person[0].name); alert(person[1].age); */ //----------------------- //案例三:对象格式里面嵌套数组格式,里面再嵌套对象格式 /* var person = { "date":[ {"name":"aaa","age":"22"}, {"name1":"bbb","age1":"20"}, {"name":"ccc","age":"21"} ] } alert(person.date[0].name); alert(person.date[1].age1); alert(person.date[2].name); */ //----------------------------- //案例四:对象里面放多个数组,每个数组里面再放对象 /* var person = { date1:[ {"name1":"lilili","age1":"19"}, {"name2":"wwwwww","age2":"18"} ], date2:[ {"name3":"ererer","age3":"33"}, {"name4":"444444","age4":"44"} ] } alert(person.date1[1].name2); alert(person.date2[0].age3); */ //----------------------- //案例五:{ /* "param1":"value1", * "param2":{}, * "param3":[{key:value,key:value},{key:value,key:value}] * } */ var person = { "param1":"val1", "param2":{"name1":"zhangsan","age1":"22"}, "param3":[ {"name2":"zhang","age2":"13"}, {"name3":"lilii","age3":"14"} ] } alert(person.param1); alert(person.param2.name1); alert(person.param3[1].age3); </script> </html>
标签:san person 引入 bbb 个数 背景 rip pre asc
原文地址:https://www.cnblogs.com/zxrxzw/p/10916503.html