首页 > 解决方案 > React.js 到痛苦的 HTML:如何将 imageupload.html 反应代码转换为 Angular 6 HTML 代码?

问题描述

onChange(e) {
      const file = e.target.files[0];
      Storage.put('example.png', file, {
          contentType: 'image/png'
      })
      .then (result => console.log(result))
      .catch(err => console.log(err));
  }

图片上传.html

<input type="file" accept='image/png' onChange={(evt) => this.onChange(evt)}/>

所以下面的代码在反应中。我怎样才能在一个 Angular 6 HTML 文件中编写下面的代码?主要是这onChange={(evt) => this.onChange(evt)}部分HTML怎么写?

如需查看原始代码:https ://docs.amplify.aws/lib/storage/upload/q/platform/js#browser-uploads

标签: javascripthtmlreactjs

解决方案


HTML 还具有 onchange 事件属性,您可以在 html 中调用该函数,例如: <input type="file" accept='image/png' onchange="onChange(this.value)"/>


推荐阅读