Javascript 敲除JS样式绑定导致错误
我需要使用knockout jsJavascript 敲除JS样式绑定导致错误,javascript,knockout.js,Javascript,Knockout.js,我需要使用knockout jsstyle属性将abackground image绑定到div。我是数据绑定产品.image。Product.image是图像文件名的字符串。但是,我需要在文件名之前添加文件的路径 代码: 这是因为您需要将背景色作为背景色使用驼峰格。请参阅:这是因为您需要使用驼色大小写作为backgroundColor的背景色。请参阅:或者,您也可以使用字符串键:样式:{background image':'url(…)}是的。你也可以:)啊,我看到我打错了。。。这是正确的数据绑
style
属性将abackground image
绑定到div
。我是数据绑定产品.image。Product.image是图像文件名的字符串。但是,我需要在文件名之前添加文件的路径
代码:
这是因为您需要将背景色
作为背景色
使用驼峰格。请参阅:这是因为您需要使用驼色大小写作为backgroundColor
的背景色。请参阅:或者,您也可以使用字符串键:样式:{background image':'url(…)}
是的。你也可以:)啊,我看到我打错了。。。这是正确的数据绑定:样式:{'background image':'url(…)}
(待完成)或者,您也可以使用字符串键:'style:{background image':'url(…)}
是的。你也可以:)啊,我看到我打错了。。。这是正确的数据绑定:样式:{'background image':'url(…)}
(待完成)
<div data-bind="style: { background-image: 'url(../../the_vegan_repository/product_images/'+ product.image + ')' }"
<script type="text/html" id="product-template">
<div class="col-sm-6 col-lg-2 clickable" style="margin-top:20px; padding: 25px;">
<div style="border-radius: 15px; border: 5px solid #fc4747;height: 270px;overflow: hidden;">
<div data-bind="style: { background-image: 'url(../../the_vegan_repository/product_images/'+ product.image + ')' }"
style= "height: 180px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
color: white;
background: center no-repeat;
background-image: url(../../the_vegan_repository/product_images/alpro_custard.jpg);
background-size:cover;
vertical-align:bottom;">
</div>
<div style="height: 90px; padding: 10px; background: #fc4747;">
<h6 class="medium-text" data-bind="text: product.name" style="text-transform: uppercase; color: white; margin-top:0; margin-bottom:5px;"></h6>
<h6 class="medium-text" data-bind="text: shop.name" style="text-transform: uppercase; color: white; margin-bottom:5px;display: inline;"></h6>
<h6 class="medium-text" data-bind="text: shop.suburb" style="text-transform: uppercase; color: white; margin-bottom:5px;display: inline;"></h6>
</div>
</div>
</div>
</script>