event.inputType在Firefox中不可用

时间:2018-11-22 05:37:46

标签: firefox events angular5

我在Safari和Chrome上使用了以下Angular 5代码,但在Firefox上却没有(63)。如何解决此问题。 (显然是因为firefox事件对象没有inputType属性。

  <input  (focus)="onInputFocus()" (keydown)="onKeyDown($event)"(input)="onSearchChange($event)" type="text" id="example-search-input">

   onSearchChange(event) {
    if (event.inputType === 'deleteContentBackward' || event.inputType === 'insertText' ) {
       // This code block doesn't get called at all in firefox.
    }
  }

Chrome上的事件对象。

InputEvent {  
   data:"e",
   dataTransfer:null,
   defaultPrevented:true,
   detail:0,
   eventPhase:0,
   inputType:"insertText",
   isComposing:false,
   isTrusted:true,
   path:(14)   [  
      input#example-search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
      div.col-md-7.search-input-container,
      div.col-12.no-padding.search.custom-search-box,
      div.input-group.col-lg-6.col-md-6.col-sm-7.col-xs-12,
      div.search-section.col-12,
      div.container,
      app-search-header,
      div.container,
      section.intro,
      app-root,
      body,
      html.no-js,
      document,
      Window
   ],
   returnValue:false,
   sourceCapabilities:null,
   srcElement:input#example-search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
   target:input#example-search-input.form-control.custom-input.ng-valid.ng-dirty.ng-touched,
   type:"input",
   view:null,
   which:0
}

firefox上的事件对象。

{  
   defaultPrevented:false,
   detail:0,
   eventPhase:0,
   explicitOriginalTarget:<input id="example-search-input" class="form-control custom-input ng-valid ng-dirty ng-touched" _ngcontent-c2="" placeholder="What are you looking for ?" type="text" ng-reflect-model="e">,
   isComposing:false,
   isTrusted:true,
   layerX:0,
   layerY:0,
   originalTarget:<input id="example-search-input" class="form-control custom-input ng-valid ng-dirty ng-touched" _ngcontent-c2="" placeholder="What are you looking for ?" type="text" ng-reflect-model="e">,
   pageX:0,
   pageY:306,
   rangeOffset:0,
   rangeParent:null,
   returnValue:true,
   srcElement:<input id="example-search-input" class="form-control custom-input ng-valid ng-dirty ng-touched" _ngcontent-c2="" placeholder="What are you looking for ?" type="text" ng-reflect-model="e">,
   target:<input id="example-search-input" class="form-control custom-input ng-valid ng-dirty ng-touched" _ngcontent-c2="" placeholder="What are you looking for ?" type="text" ng-reflect-model="e">,
   view:   Window http:   //localhost:4200   /search-results,
   which:0
}

省略了对象中一些明显不相关的元素,以使帖子更短。

0 个答案:

没有答案