What's the difference between getting access to a view model's values through the binding properties (via valueAccessor) and getting them from the viewModel argument passed to the handler's init and update? I have always assumed the answer is that those model properties linked to valueAccessor automatically set up bindings (which would fire an update on any change to observables) but I'm not sure about that.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The valueAccessor
argument gives you access to specifically what was passed into the binding, while the viewModel
argument gives you access to the entire data object at the scope.
So, if someone says text: firstName
valueAccessor()
would give you the firstName
observable/property and viewModel
would give you access to the object that contains firstName
.
标签:
knockout.js