在同时绑定图像和文本时不显示淘汰图像

Knockout Image Not display while binding image and text at same time

本文关键字:图像 显示 淘汰 文本 绑定      更新时间:2023-09-26

下面的knockout绑定永远不会显示图像。

  <p data-bind="text: $data.Title, attr:{onClick: 'variableName.CollapseExpandCustom.ToggleSection('''+$data.Hsim+''')'} " class="primaryCaseHeader"><img src="~/Images/Collapse.png" /></p>

我只能看到文字。图片从未显示过。

谁能帮助我如何显示图像和文本在同一时间。

你正在尝试覆盖图像内容,因为它被放置在两个<p>标签之间,因为textp绑定将覆盖它

解决方法是在<span>标签上使用数据绑定。

视图:

<p> <span data-bind="text: $data.Title, attr:{onClick: 'variableName.CollapseExpandCustom.ToggleSection('''+$data.Hsim+''')'} " class="primaryCaseHeader"></span><img src="~/Images/Collapse.png" /></p>

现在它将显示图像和文本并排。

工作样本此处