首页 > 其他 > 详细

dict字典

时间:2017-09-21 18:33:59      阅读:347      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Dict</title>
</head>
<body>

</body>
<!--测试字典功能-->
<script>
const dictJsonStr = {
"agentType": [
{
"key": "1",
"name": "律师代理"
},
{
"key": "2",
"name": "公民代理"
}
],
"commission": [
{
"key": "123456",
"name": "广州仲裁委员会"
}
],
"litigantType": [
{
"key": "1",
"name": "申请人"
},
{
"key": "2",
"name": "被申请人"
},
{
"key": "3",
"name": "第三人"
}
]
};
function getDictName(dict, key){
childDict = dictJsonStr[dict];
for (i=0;i<childDict.length;i++){
if(childDict[i].key == key) {
return childDict[i];
}
}
}
getDictName("litigantType", 3).name;//可直接用此方法进行查询
console.log("字典",dictJsonStr,dictJsonStr["litigantType"]);
console.log("字典2",dictJsonStr,dictJsonStr.litigantType);
console.log("字典查询",getDictName("litigantType", 3).name)

</script>
</html>

dict字典

原文:http://www.cnblogs.com/CrystalPeng/p/7569804.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!