0
我使用signalr到prepand行到表,但我不能這樣做:前面加上一個行到表
HTML:
<div>
<table>
<thead>
<tr>
<td>Name</td>
<td>Price</td>
</tr>
</thead>
<tbody data-bind="foreach: Products">
<tr>
<td><span data-bind="text: name"></span></td>
<td><span data-bind="text: price"></span></td>
</tr>
</tbody>
</table>
</div>
淘汰賽:
function ProductViewModel() {
Products = ko.observableArray();
Products.unshift(
{
name: Products.name,
price: Products.price
}
);
}
ko.applyBindings(new ProductViewModel());
SignalR:
chat.client.hello = function (product) {
console.log(product.name);
ProductViewModel.Product(product);
};
什麼是不工作,併發生呢?你有任何錯誤? – nemesv