我正在尝试使用firefox中的knockout将焦点设置为第一个输入。我已尝试过两种自动对焦装订。并设置自动聚焦属性。但似乎都没有在Firefox中工作。它看起来似乎在边缘和ie11(我不能在工作中尝试使用chrome,因为它被阻止了......不要问)
https://jsfiddle.net/0o89pmju/44/
ko.components.register('inquiry-form', {
viewModel: function(params) {
this.label = params.label;
this.value = params.value;
this.placeholder = params.placeholder;
this.id = params.id;
this.maxlength = params.maxlength;
this.autofocus = params.autofocus;
this.isSelected = ko.observable(params.autofocus);
},
template: '<div class="form-group">\
<label data-bind="attr: {for: id}"> \
<span data-bind="text: label"></span>: \
</label> \
<input type="text" class="form-control" data-bind="textInput: value, attr: {id: id, placeholder: placeholder, maxlength: maxlength, autofocus: autofocus}, hasFocus: isSelected" />\
</div>'
});