我正在使用以下模板与剔除js
<tbody data-bind="foreach: List">
<tr>
<td><input type="button" data-bind="if: ($parent.IsFVL || $parent.AllowChat || $root.Me().AllowChatMonitoring), value: ID, click: SelectVisit" /><span data-bind="ifnot: ($parent.IsFVL || $parent.AllowChat || $root.Me().AllowChatMonitoring), text: ID"></span></td>...
并像这样调用/启动模板
<div data-bind="template: { name: 'tplVisitsGrid', data: { Title: 'My Visits', 'List': MVL, 'AllowChat': true, 'AllowPing': false, 'IsFVL': false } }"></div>
此外,我还仔细检查了“ $ root.Me()。AllowChatMonitoring”的值为true,但input [type = button]和span都在呈现。我可能会缺少什么?
访问IsFVL,AllowChat等时,您不应使用$parent
。尝试将模板更新为以下内容:
<input type="button" data-bind="if: (IsFVL || AllowChat || $root.Me().AllowChatMonitoring), value: ID, click: SelectVisit" />
<span data-bind="ifnot: (IsFVL || AllowChat || $root.Me().AllowChatMonitoring), text: ID"></span></td>
如果这无济于事,请摆弄您的问题。