[英]knockout.js data-bind style with border-radius
I am trying to apply border-radius css attribute using knockout.js data-bind attribute: 我正在尝试使用kickout.js数据绑定属性来应用border-radius css属性:
data-bind="style: { width: totalLength() < workDay ? totalLength() + 'px' : workDay + 'px', border-radius: '10px', background: '#a9fd76' }"
but the browser doesn't seem to like it at all. 但浏览器似乎一点都不喜欢它。 I get an error from
knockout.js
file saying: 我从
knockout.js
文件中收到一条错误消息:
"Error: Unable to parse bindings. Message: SyntaxError: missing : after property id; Bindings value: style: { width: totalLength() < workDay ? totalLength() + 'px' : workDay + 'px', border-radius: '10px', background: '#a9fd76' }"
“错误:无法解析绑定。消息:语法错误:缺少:在属性ID之后;绑定值:样式:{width:totalLength()<workDay?totalLength()+'px':workDay +'px',border-radius: '10px',背景:'#a9fd76'}“
Does it mean that CSS3 attributes are not supported by knockout.js bindings? 这是否意味着ockoutout.js绑定不支持CSS3属性?
Just to mention everything works fine when I take border-radius attribute out. 提及我将border-radius属性删除时,一切工作正常。
You need to write it as: 您需要将其编写为:
borderRadius
as border-radius is not a valid javascript name. 因为border-radius不是有效的javascript名称。
You can see more examples at the bottom of the documentation on it. 您可以在文档底部看到更多示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.