我有Vue组件。在data()中,我声明了变量来存储选定的行
data() {
return {
selectedTableElemRow: null,
然后在方法中我尝试将所选行分配给此变量:
let tableElemRow = tableElementCell.parentElement;
if (tableElemRow != null) {
if (!this.isTableRowElement(tableElemRow)) {
tableElemRow = tableElemRow.parentElement;
}
}
if (tableElemRow != null) {
this.selectedTableElemRow = tableElemRow as HTMLTableRowElement;
}
我得到错误:
Severity Code Description Project File Line Suppression State
Error TS2322 (TS) Type 'HTMLTableRowElement' is not assignable to type '{ new (): HTMLTableRowElement; prototype: HTMLTableRowElement; }'. ClientApp (tsconfig project)
答案 0 :(得分:0)
变量的声明应该是:
data() {
return {
selectedTableElemRow: null as any,