Ionic2 爱奥尼亚3(或爱奥尼亚2):使用<;输入类型=";文件"&燃气轮机;
我正在将一个Ionic 1应用程序迁移到Ionic 3(甚至Ionic 2),而我似乎无法访问用户选择的文件的JSON内容 我有以下内容:Ionic2 爱奥尼亚3(或爱奥尼亚2):使用<;输入类型=";文件"&燃气轮机;,ionic2,ionic3,Ionic2,Ionic3,我正在将一个Ionic 1应用程序迁移到Ionic 3(甚至Ionic 2),而我似乎无法访问用户选择的文件的JSON内容 我有以下内容: <input type="file" name="file" (change)="fileSelected($event)"> 但我似乎无法获取文件的内容(在本例中,它只是JSON) 有什么建议吗? 谢谢…我想起来了: fileSelected(ev) { let myFile = ev.target.files[0]; let rea
<input type="file" name="file" (change)="fileSelected($event)">
但我似乎无法获取文件的内容(在本例中,它只是JSON)
有什么建议吗?
谢谢…我想起来了:
fileSelected(ev) {
let myFile = ev.target.files[0];
let reader = new FileReader();
reader.readAsText(myFile);
reader.onload = (ev) => {
this.fileJSON = reader.result;
}
}
fileSelected(ev) {
let myFile = ev.target.files[0];
let reader = new FileReader();
reader.readAsText(myFile);
reader.onload = (ev) => {
this.fileJSON = reader.result;
}
}