Last active
February 19, 2019 08:00
-
-
Save summerscar/0eaa5866a8b9f9096c8ccd3c20f472dc to your computer and use it in GitHub Desktop.
文件导入导出
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
| function exportData(text) { | |
| const saveLink = document.createElement('a') | |
| document.body.appendChild(saveLink) | |
| const data = new Blob([text], { type: 'text' }) | |
| const url = window.URL.createObjectURL(data) | |
| saveLink.href = url | |
| // File name: project-DATE-TIME | |
| const date = new Date() | |
| const timestamp = `${date.toLocaleDateString()}-${date.toLocaleTimeString()}` | |
| saveLink.download = `block.${timestamp}.svg` | |
| saveLink.click() | |
| window.URL.revokeObjectURL(url) | |
| document.body.removeChild(saveLink) | |
| } | |
| dom.change =function(e) { | |
| const reader = new FileReader(); | |
| reader.onload = function() { | |
| console.log(reader.result) | |
| } | |
| reader.readAsText(e.target.files[0]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment