javascript - 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
解决方案
HTML 还具有 onchange 事件属性,您可以在 html 中调用该函数,例如:
<input type="file" accept='image/png' onchange="onChange(this.value)"/>
推荐阅读
- vue.js - Vue 观察者和组件
- php - 使用 url 行从 txt 获取文件大小
- npm - 为什么 npm 将 cmd 行标志直接传递给我的脚本?
- python - 将 UT(通用时间)转换为 JD(儒略日期)(天文学)
- ios - 具有旋转闪烁动画的自定义指示器,如 UIActivityIndicatorView
- ios - 只显示我的浮点数到某个小数位 - Swift
- python - 从另一个整数列表中按索引从列表中删除元素
- javascript - 量角器:自动 .sendKeys() 将我的文本转换为大写字母
- c# - 拖放事件后关联项目列表
- capl - 如何在 CAPL 的诊断请求中设置 DTC 状态位?