我想使用带有敲除的安全绑定。为此,我使用了knockout-secure-binding.js。
谁能解释为什么下面的代码不起作用?它抛出一个错误`
未捕获的 #< 对象 > 淘汰赛-secure-binding.js:74`
行后ko.applyBindings(new viewModel());
<html>
<head>
<title></title>
<script src="scripts/knockout-3.0.0-min.js"></script>
<script src="knockout-secure-binding-master/dist/knockout-secure-binding.js"></script>
</head>
<body>
<button type="button" data-sbind="sbtnClick">button</button>
<script>
var bindings = {
sbtnClick: function () {
return {click: this.btnClick};
}
};
var viewModel = function () {
this.btnClick = function () {
alert('clicked');
};
};
ko.bindingProvider.instance = new ko.secureBindingsProvider(bindings);
ko.applyBindings(new viewModel());
</script>
</body>
</html>