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?
認(rèn)證高級PHP講師
No react involved
const data = "..." // 這里填CSV內(nèi)容的字符串
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)