0

我想在打字稿中使用handsontable

$("#dataTable").handsontable({
    data: data,
    startRows: 5,
    startCols: 5,
    minSpareRows: 1,
    contextMenu: true,
    onSelection: function (row, col, row2, col2) {
        var meta = container.handsontable('getCellMeta', row2, col2);
        if (meta.isWritable == false) {
            container.handsontable('updateSettings', { fillHandle: false });
        }
        else {
            container.handsontable('updateSettings', { fillHandle: true });
        }
    },
    cells: function (row, col, prop) {
        var cellProperties = {};
        if (row === 0 || container.handsontable('getData')[row][col] === 'readOnly') {
            cellProperties.readOnly = true; //make cell read-only if it is first row or the text reads 'readOnly'
        }
        cellProperties.type = {
            renderer: negativeValueRenderer
        }
        return cellProperties;
    }
});

但我得到错误:

Error   1   The property 'readOnly' does not exist on value of type ''. 
Error   3   The property 'type' does not exist on value of type ''. 

我该如何解决?

4

1 回答 1

0

TypeScript 编译器不喜欢你的空对象。它没有关于其类型或可能存在的属性的信息。

最简单的是根据这个问题

var cellProperties:any = {}
于 2013-08-06T16:44:58.597 回答