Javascript 使用对象删除表绑定

Javascript 使用对象删除表绑定,javascript,jquery,knockout.js,Javascript,Jquery,Knockout.js,我有一个javascript对象,我想使用KnockoutJS绑定到一个表 这是我的目标: var data = { "Warnings": { "numbers": 30, "content": [ { "number" : 3001, "description" : "There may be a problem with the device you are using if you use the default profi

我有一个javascript对象,我想使用KnockoutJS绑定到一个表

这是我的目标:

var data = {
  "Warnings": {
    "numbers": 30,
    "content": [
      {
        "number" : 3001,
        "description" : "There may be a problem with the device you are using if you use the default profile"
      },
        {
        "number" : 3002,
        "description" : "There may be a problem with the device you are using if you don't use the default profile"
      }
    ]
  },
  "Errors": {
    "numbers": 20,
    "content": [
      {
        "number": 1000,
        "description": "No network is loaded"
      },
        {
        "number": 1000,
        "description": "No network is loaded"
      }
    ]
  }
};
ko.applyBindings(data);
以下是我的html代码:

<table class="table table-hover">
    <thead>
       <tr>
           <th style="width:100px">Numero</th>
           <th>Description</th>
       </tr>
    </thead>
    <tbody data-bind="foreach: Warnings.content">
        <tr data-bind="foreach: $data">
            <td data-bind="text: $data.number"></td>
            <td data-bind="text: $data.description"></td>
        </tr>
    </tbody>
</table>

头号人物
描述
下面是一个JSFIDLE:

我真的需要对我的数据对象使用这种格式


我不知道为什么我没有在表中列出警告,因为我没有收到任何错误…

您有一个额外的
foreach
,这是不需要的。只需删除
tr
上的
foreach
tbody
上的
foreach
将为循环中呈现的每个tr的
$data
分配一个新值