首页 > 解决方案 > 尝试添加下载按钮

问题描述

我正在一个项目中工作,我正在尝试添加一个下载按钮,但我找不到方法。我正在显示要添加按钮的部分代码。

        axios.post("/notas",data)
            .then(response => {
                //console.log(response.data);
                const cols = [];
                const rows = [];
                response.data.columns.forEach((col,index)=>{
                    cols.push({
                        title: col,
                        dataIndex:col.toLowerCase(),
                        key:col.toLoweSrCase()
                        button: <button onClick={activateLasers}>  Activate Lasers
                        </button>

                    })
                });
                console.log(cols);
                response.data.data.forEach((row,index)=>{
                    let newRow = {key:index+1};
                    row.forEach((elem,index)=> {
                        //console.log(cols[index]);
                        newRow[cols[index].key] = elem;
                    });
                    rows.push(newRow);
                });
                console.log(rows);
                this.setState({
                    loading:false,
                    notas:{
                        columns:cols,
                        dataSource:rows
                    },
                    deleted: false
                })
                console.log(this.state.notas.dataSource);
            })
            .catch(err => {
                this.setState({loading:false});
                console.log(err);
            });
    }

这是我要添加按钮的部分。感谢您的回答

标签: reactjsbuttondownload

解决方案


推荐阅读