我是新手做出反应,我希望能够做到这一点。我的页面中有网格,它显示数组中的一些数据。我希望在我的状态中定义多个对象,如下所示。
take
中的skip
和query
属性必须由pagingOptions
filter
中的query
内的filter
必须由Uncaught TypeError: Cannot read property 'filter' of undefined
对象设置
现在它给我一个错误:this.state = {
// filter for my grid view
filter: {
id: 1,
status: ""
etc....
},
// paging options for grid
pagingOptions:{
pageSize: 5,
skip: 0
},
//this represents query which is send to my api
query:{
collectionName: "",
filter: this.state.filter // here it throws an error: Cannot read property 'filter' of undefined
sort: {},
projection: {},
take: this.state.pagingOptions.pageSize, // it will throw error also here since its same approach as filter
skip: this.state.pagingOptions.skip // it will throw error also here since its same approach as filter
includeTotalCount: true,
context: null,
}
};
如何将这些属性设置为其值?
具有这些状态的我的组件如下所示:
Option Explicit
Public Sub TEST()
Dim my_Array()
my_Array = [A1].CurrentRegion.Value
AutoRange my_Array
End Sub
Public Sub AutoRange(ByVal my_Array As Variant)
Dim nb_rows As Long, nb_cols As Long
Dim current_cell As Range
nb_rows = UBound(my_Array, 1)
nb_cols = UBound(my_Array, 2)
Set current_cell = Selection
current_cell.Resize(nb_rows, nb_cols).FormulaArray = current_cell.Formula
End Sub
答案 0 :(得分:1)
您试图在this.state
有值this.state
之前引用undefined
的属性,因此会出现您提到的错误消息。
要解决此问题,您可以在定义后将query
属性添加到状态对象:
this.state = {
// ...
};
this.state.query = {
// ...
};