我想在拖动时更新左侧属性,但拖动时我的属性仍然显示 50。我知道我做的不对,有什么帮助吗?
games: ko.observableArray([
{ left: ko.observable(50) },
{ left: ko.observable(50) },
{ left: ko.observable(50) }
];
<div class="bracket-game" data-bind="bracketGameInit: { left: left }">
ko.bindingHandlers.bracketGameInit = {
init: function (element, valueAccessor) {
var values = ko.utils.unwrapObservable(valueAccessor());
$(element).draggable();
ko.bindingHandlers.style.update(element, function () { return { left: (values.left() + 'px') }; });
}
};