javascript - 带边框半径的 knockout.js 数据绑定(bind)样式

标签 javascript css data-binding knockout.js

我正在尝试使用 knockout.js 数据绑定(bind)属性应用 border-radius css 属性:

data-bind="style: { width: totalLength() < workDay ? totalLength() + 'px' : workDay + 'px', border-radius: '10px', background: '#a9fd76' }"

但是浏览器好像一点都不喜欢。我从 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' }"

这是否意味着 CSS3 属性不受 knockout.js 绑定(bind)的支持?

只是提一下,当我去掉 border-radius 属性时一切正常。

最佳答案

你需要这样写:

borderRadius

因为 border-radius 不是有效的 javascript 名称。

您可以在 documentation 的底部看到更多示例在上面。

关于javascript - 带边框半径的 knockout.js 数据绑定(bind)样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15268213/

相关文章:

javascript - 无法将 DIV 元素居中

javascript - 在 "Warning: setState(...): Can only update a mounted or mounting component."函数中设置状态时出现 "FB.Event.subscribe()"错误

html - 为什么 float 在转义到下一行时会保留 "phantom"空间?

wpf - 选中的列表框 (WPF)

c# - 使用 LINQ 获取 1-2-3 分数并将其绑定(bind)到 View

Android dataBinding - 无法通知更改 View

javascript - 将 "more results..."文本添加到 ui bootstrap typeahead

javascript - 创建一堆空对象的更好方法

javascript - 使用 Webpack 捆绑单独的 CSS

html - 带有文本的背景图像