作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以用 knockout 执行这样的绑定(bind)吗
<div data-bind="attr:{id: id,'data-plugin-options': options}">
我的模型看起来像
var model = {
id: id,
options: {
headerText: 'Group',
headerStyle: 'groupWithBorders'
}
};
ko.applybindings(model);
目前,在绑定(bind)发生后,我在数据插件选项上获得 [object object]。
最佳答案
Knockout 使用 toString() 将 attr 绑定(bind)中的对象转换为字符串。您可以重载该函数以输出您想要的结果:
var model = {
id: id,
options: {
headerText: 'Group',
headerStyle: 'groupWithBorders',
toString: function() {
return JSON.stringify(this);
}
}
};
关于javascript - 将对象传递给挖空 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16590957/
我正在尝试在 CSS 中找到一种创建蒙版的好方法,在该蒙版中,蒙版被剔除,我可以在它后面传递另一个图像或 div。 这里是我尝试使用的示例 http://jsfiddle.net/LxBM5/该示例中
我有这段代码。 问题是它显示了两个图像。一个是来自 src 的图像,另一个是来自 background 图像的图像。我的目标是在 src 图像不可用时启用 background 图像。 最佳答案 您
我是 Knockout 和 Visual Studio Code(在 Mac 上)的新手。 我创建了一个 html 文件,里面有我的 与我所有的 knockout 代码。都好。然后我创建了一个单独的
我是一名优秀的程序员,十分优秀!