当我将鼠标放在上面时,如何避免高度 [ko.computed] 重复运行?[ mouseAreHoverFotoBanner ]
当从 ui 读取内容时,所有 ko.computed 都会自动执行...
代码示例 [js]:
var ui = 函数 () {
var fotoBanner = {
scale: scale,
scaleIn: function () { scale(0.9); },
scaleOut: function () { scale(scale(0)); },
mouseAreHoverFotoBanner: mouseAreHoverFotoBanner,
enableHoverFotoBanner: function () { ( (mouseAreHoverFotoBanner()) ? "" :mouseAreHoverFotoBanner(true)); },
disabelHoverFotoBanner: function () { mouseAreHoverFotoBanner(false); },
url: ko.observable("270829_184226781631642_1559736_n.jpg"),
height: ko.computed(function () {
toastr.info((this.wd.height() * scale()) + "px");//debug
return (this.wd.height() * scale()) + "px";
}, this)
};
return { fotoBanner: fotoBanner };
};