Onclick 使用淘汰赛 js 绑定图像 [英] Onclick bind image using knockout js
本文介绍了Onclick 使用淘汰赛 js 绑定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示来自 allDoorColorStandard 的图像.
HTML:
点击颜色数据";div ,我想更新图像.在警报中,我正在获取图片 URL,现在需要绑定到图片标签中.
<div data-bind="foreach: { data: doorColorList, as: 'doorStyleType' }"><img 类 =mappimg";宽度=45"高度=45"alt="data-bind="attr: {src: $parent.mappingImage}";if="$parent.mappingImage"><div data-bind="foreach: { data: Object.values(doorStyleType.colors.standard) , as: 'allDoorColorStandard' }"><div class="color-data";数据绑定=点击:$parents[1].selectColor"><span class="style-name";data-bind="text: allDoorColorStandard.color_name"></span>
JS:
selectColor: function (styleColor,color) {警报('kkkk'+styleColor.mapping_image);self.mappingImage(styleColor.mapping_image);},
任何帮助将不胜感激.
解决方案
您是否收到任何错误消息?不看你的数据/虚拟机的结构有点难以看清.属性mappingImage
是否属于doorColorList
数组?
I want to show image from allDoorColorStandard.
HTML:
Onclick "color-data" div , i want to update image. In alert i'm getting image URL, now need to bind in image tag.
<div data-bind="foreach: { data: doorColorList, as: 'doorStyleType' }">
<img class="mappimg" width="45" height="45" alt="" data-bind="attr: {src: $parent.mappingImage}" if="$parent.mappingImage">
<div data-bind="foreach: { data: Object.values(doorStyleType.colors.standard) , as: 'allDoorColorStandard' }">
<div class="color-data" data-bind="click: $parents[1].selectColor">
<span class="style-name" data-bind="text: allDoorColorStandard.color_name"></span>
</div>
</div>
</div>
JS:
selectColor: function (styleColor,color) {
alert('kkkk'+styleColor.mapping_image);
self.mappingImage(styleColor.mapping_image);
},
Any help will be appreciated.
解决方案
Are you receiving any error messages at all? It is a bit difficult to see without seeing the structure of your data/vm. Does the property mappingImage
belong to the doorColorList
array?
这篇关于Onclick 使用淘汰赛 js 绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!