Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS读取上传的文本文件内容 #23

Open
klren0312 opened this issue Apr 19, 2019 · 0 comments
Open

JS读取上传的文本文件内容 #23

klren0312 opened this issue Apr 19, 2019 · 0 comments
Labels
JS js相关问题

Comments

@klren0312
Copy link
Owner

klren0312 commented Apr 19, 2019

<label for="file-import" class="import-btn">
...
</label>

 <input style="display: none;" id="file-import" type="file" @change="fileChange" accept=".txt">
fileChange (e) {
  const file = e.target.files[0]
  const reader = new FileReader()
  reader.onload = (evt) => {
    this.importContent = evt.target.result
  }
  reader.readAsText(file)
}

参考资料

@klren0312 klren0312 added the JS js相关问题 label Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS js相关问题
Projects
None yet
Development

No branches or pull requests

1 participant