1. Use in react
2. Accept json data from the background and convert json to CSV
3. The user clicks the button button to download the CSV file
How to achieve this?
曾经蜡笔没有小新2017-06-26 10:55:11
No react involved
const data = "..." // 这里填CSV内容的字符串
const blob = new Blob([data], {type: "text/plain"})
const link = document.createElement("a")
link.href = URL.createObjectURL(blob)
link.download = "filename.csv" // 这里填保存成的文件名
link.click()
URL.revokeObjectURL(link.href)