0

我正在尝试上传图像,然后单击旋转它,但由于某种原因,此功能不适用于任何 iPhone。

HTML

 <input type="file" id="avatar" name="avatar" accept="image/png, 
  image/jpeg" />
  <div id="vanilla" class="col-md-10 col-xs-12"></div>
  <div class="actions col-md-2 col-xs-12">
      <button class="vanilla-rotate rotate" (click)="rotate($event)" 
       data-deg="-90">Rotate Left</button>
      <button class="vanilla-rotate rotate" (click)="rotate($event)" 
       data-deg="90">Rotate Right</button>
      <button class="vanilla-result done 
       (click)="buttonClick()">Done</button>
  </div>
</div>`

JS

var inputFile = $('#avatar');
      console.log(that);
      inputFile.on('change', function(e: any){
            console.log(inputFile.val(), e, window.URL.createObjectURL(e.originalEvent.srcElement.files[0]));

          that.vanilla.bind({
              url: window.URL.createObjectURL(e.originalEvent.srcElement.files[0]),
              orientation: 1
          });
      })

 rotate(e: any) {
    console.log(e, $(e.path[0]).data());
    this.vanilla.rotate(parseInt($(e.path[0]).data('deg')));
  }

控制台错误

typeerror undefined is not an object (evaluating 't.path[0]')
4

0 回答 0