First we have to define a function and then call the function on click.
Below is an example of the downloading a file. Create a folder name "downloadformat" in public folder
const onClickExport = () => {
const link = document.createElement("a");
link.href = `${window.location.origin}/downloadformat/xxxx.csv`;
link.setAttribute("download", `download-format.csv`);
document.body.appendChild(link);
link.click();
};
<button
className="btn btn-custom btn-secondary buttons-html5"
type="button"
onClick={onClickExport}
>Download Format</button>
Comments
Post a Comment