如何使用rivets.js访问json响应对象?

时间:2013-05-27 16:17:45

标签: json html5 backbone.js requirejs rivets.js

任何人都可以帮助我,因为我是rivets.js的新手。我在html页面中访问JSON响应时遇到问题。我可以使用account.subTotal访问“subTotal”键,但无法访问货币(内部键)等。以下是我的JSON响应:

[
{
    "subTotal": [
        {
            "currency": "dollar",
            "balance": "979,18"
        }]
    ,
    "productList": [
        {
            "acctno": "123456789",
            "Name": "abc",

        }
    ]
},
{
    "subTotal": [
        {
            "currency": "dollar",
            "balance": "979,18"
        }]
    ,
    "productList": [
        {
            "acctno": "123456789",
            "Name": "abc",

        }
    ]
},
{
    "subTotal": [
        {
            "currency": "dollar",
            "balance": "979,18"
        }]
    ,
    "productList": [
        {
            "acctno": "123456789",
            "Name": "abc",

        }
    ]
}

以下是我在HTML模板中添加的内容:

<ul>
<li data-each-account="model">
    <a href="#">
    <strong data-text="account.subTotal.currency"></strong><br/>
    </a>
    </li>
</ul>                       

提前致谢!

1 个答案:

答案 0 :(得分:0)

data-text="account.subTotal || attr currency">