1. Use in react2. Accept json data from the background and convert json to CSV3. The user clicks the button button to download the CSV file
How to achieve this?
认证高级PHP讲师
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)
No react involved