Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * downloadLocalJson(jsonObject, fileName)
- * 根据 jsonObject 下载 json 文件
- * @param jsonObject json对象
- * @param fileName 文件名称
- */
- export default (jsonObject, fileName) => {
- const URL = window.URL
- const blob = new window.Blob(
- [JSON.stringify(jsonObject, null, 2)],
- { type: 'application/octet-stream' }
- )
- const url = URL.createObjectURL(blob)
- const a = document.createElement('a')
- a.href = url
- a.download = fileName
- a.click()
- URL.revokeObjectURL(url)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement