Created
May 24, 2021 05:53
-
-
Save wewindy/f0479fdcf20433122a90827815a92ce7 to your computer and use it in GitHub Desktop.
异步选择文件或文件夹 API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button id="btn">ClickMe</button> | |
| <script> | |
| const btn = document.getElementById('btn') | |
| let fileHandle | |
| btn.addEventListener('click', async () => { | |
| [fileHandle] = await window.showOpenFilePicker() | |
| const file = await fileHandle.getFile() | |
| const contents = await file.text() | |
| console.log(contents) | |
| }) | |
| </script> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.cnblogs.com/ajanuw/p/13788051.html
一篇详尽的文章