Javascript 无法在firefox中的组件上的敲除中设置自动聚焦属性
我试图在firefox中使用knockout将焦点设置为第一个输入。我尝试了两种自动对焦绑定。以及设置自动聚焦属性。但两者似乎都不适用于firefox。它似乎在edge和ie11中也能工作(我不能在工作时尝试chrome,因为它被阻止了……不要问)Javascript 无法在firefox中的组件上的敲除中设置自动聚焦属性,javascript,firefox,knockout.js,autofocus,Javascript,Firefox,Knockout.js,Autofocus,我试图在firefox中使用knockout将焦点设置为第一个输入。我尝试了两种自动对焦绑定。以及设置自动聚焦属性。但两者似乎都不适用于firefox。它似乎在edge和ie11中也能工作(我不能在工作时尝试chrome,因为它被阻止了……不要问) ko.components.register('inquiry-form'{ viewModel:函数(参数){ this.label=params.label; this.value=params.value; this.placeholder=
ko.components.register('inquiry-form'{
viewModel:函数(参数){
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.可观察(参数自动对焦);
},
模板:'\
\
: \
\
\
'
});
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>'
});