Data binding 使用数据绑定到图像src属性的敲除模板无效

Data binding 使用数据绑定到图像src属性的敲除模板无效,data-binding,knockout.js,knockout-templating,Data Binding,Knockout.js,Knockout Templating,我看不出这里有什么问题,但使用以下敲除模板不会显示图像: <script type="text/html" id="legend-template"> <div><input type="checkbox" data-bind="click : doSomething" ></input> <img width="16px" height="16px" data-bind="src: 'imagePath

我看不出这里有什么问题,但使用以下敲除模板不会显示图像:

<script type="text/html" id="legend-template">       
    <div><input type="checkbox" data-bind="click : doSomething" ></input>
        <img width="16px" height="16px" data-bind="src: 'imagePath'" />          
        <span data-bind="text : label"> </span>
    </div>        
</script>
呈现HTML对象时,我看到标签,单击复选框调用doSomething


TIA.

只有少数属性可以直接绑定;尝试使用
attr
——它将允许您在元素上设置任何属性

<img width="16px" height="16px" data-bind="attr:{src: imagePath}" />  


感谢您的回复,但如果出现以下错误:Microsoft JScript运行时错误:无法解析绑定。消息:SyntaxError:应为“:”;绑定值:attr{src:imagePath}明白了,谢谢。对此应该感到抱歉——#自我提醒:不要再在看《死硬3》时回答问题;)仅供参考:图像标签宽度和高度属性不应该有“px”,我使用的是最新版本3.4.0,这个答案仍然适用。
<img width="16px" height="16px" data-bind="attr:{src: imagePath}" />