我可以创建一个jsrender模板来访问这个json对象中的'first'和'age'值吗?
<script type="text/javascript">
var names = {
"smith": [
{
"first" : "bill",
"age" : "21"
}
],
"jones": [
{
"first" : "mary",
"age" : "25"
}
]
};
</script>
答案 0 :(得分:1)
架构看起来很奇怪。但你可以这样写:
<script id="myTmpl" type="text/x-jsrender">
{{:smith[0].first}}: Age: {{:smith[0].age}}
{{:jones[0].first}}: Age: {{:jones[0].age}}
</script>