很抱歉这个新手问题,但我在任何地方的文档中都看不到这个:
http://knockoutjs.com/documentation/click-binding.html
<div>
You've clicked <span data-bind="text: numberOfClicks"></span> times
<button data-bind="click: incrementClickCounter">Click me</button>
</div>
<script type="text/javascript">
var viewModel = {
numberOfClicks : ko.observable(0),
incrementClickCounter : function() {
var previousCount = this.numberOfClicks();
this.numberOfClicks(previousCount + 1);
}
};
</script>
如果我想要根据单击鼠标左键、右键还是中键来执行不同的操作怎么办?是否有特定的绑定,或者您是否挂钩事件并使用 event.which 或其他东西?