javascript - How to convert json data to CSV file and download it
PHP中文网
PHP中文网 2017-06-26 10:53:11
0
1
1129

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?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all (1)
曾经蜡笔没有小新

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)
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!