反应引导表中导出到csv自定义按钮的问题

时间:2018-08-02 19:06:31

标签: react-bootstrap-table export-csv

我在代码中有一个自定义导出到csv按钮,该按钮调用了引导表上的handleExportCSV()函数。但是,这是一个错误-'Uncaught TypeError:无法读取未定义的属性'export''

这是代码段:

    ...
function renderTable(record_set, columns, per_page_list, size_per_page, column_format) {
    var ReactBsTable = window.BootstrapTable;
    var Table = function (_React$Component) {
        _inherits(Table, _React$Component);

        function Table() {
            _classCallCheck(this, Table);

            var _this = _possibleConstructorReturn(this, (Table.__proto__ || Object.getPrototypeOf(Table)).call(this));

            _this.state = {};
            return _this;
        }

        _createClass(Table, [{
            key: 'handlerClickExportCsv',
            value: function handlerClickExportCsv() {
                this.refs.bootstrapTable.handleExportCSV();
            }
        },
            {
            key: 'render',
            value: function render() {
                var options = {
                    ...
                };

                var columnsList = columns.map(function (column, index) {
                        var colRef = 'columnref' + (index + 1);
                        this.state[colRef] = false;

                        return React.createElement(
                                TableHeaderColumn,
                                {   
                                    ref: colRef,
                                    dataField: column,
                                    hidden: this.state[colRef],
                                },
                                column
                        );
                }, this);

                return React.createElement(
                    'div',
                    { id: 'bootstrapTableContainer' },
                    React.createElement(
                        'button',
                        { type: 'button', onClick: this.handlerClickExportCsv.bind(this), className: 'btn btn-success react-bs-table-csv-btn'},
                        'Export to CSV'
                    ),
                    React.createElement(
                        BootstrapTable,
                        { ref: 'bootstrapTable', data: record_set, ... },
                        columnsList
                    )
                );
            }
        }]);

        return Table;
    }(React.Component);

    ReactDOM.render(React.createElement(Table, null), document.getElementById("..."));
}

该函数被调用,但是某种程度上该错误来自reactdom js。

0 个答案:

没有答案