我想更新我的listview行,因为我正在尝试对listview数据源进行切片,但是它提出了以下错误:
this.state.dataSource.slice不是一个函数。 (在 'this.state.dataSource.slice()','this.state.dataSource.slice'是 未定义)
这是我的代码:
let newArray = this.state.dataSource.slice();
newArray[indexToUpdate] = {
//Here I am updating my values.
};
this.setState({
dataSource: this.state.dataSource.cloneWithRows(newArray),
});
如果我的代码中有任何错误或我做错了,请告诉我。
答案 0 :(得分:5)
Option Explicit
Sub List()
On Error GoTo Message
ActiveSheet.DisplayPageBreaks = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Long
Dim i2 As Long
Dim i3 As Long
Dim j2 As Long
Dim name As String
Dim Txt As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\TestMe\Arch")
For Each objFile In objFolder.Files
Debug.Print objFile
Next objFile
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Exit Sub
Message:
Application.DisplayAlerts = False
Exit Sub
End Sub
不是数组,这就是为什么你不能在dataSource上this.state.dataSource
。看起来像这样
slice()
您所需的数组位于该对象的{ _rowHasChanged: [Function: rowHasChanged],
_getRowData: [Function: defaultGetRowData],
_sectionHeaderHasChanged: [Function],
_getSectionHeaderData: [Function: defaultGetSectionHeaderData],
_dataBlob: { s1: [ 'row 1', 'row 2' ] },
_dirtyRows: [ [ true, true ] ],
_dirtySections: [ true ],
_cachedRowCount: 2,
rowIdentities: [ [ '0', '1' ] ],
sectionIdentities: [ 's1' ]
}
键中。
注意:它工作正常并使用以下行更新listview dataSource
_dataBlob