我刚刚开始学习颤振,我很好奇我如何00 00 00 00
动态地颤动
在setState()
中,我通常动态地使用如下函数来React Native
:
setState
class foo extends React.Component{
state={
username:null,
password:null
}
toggleSetState(whatState, value){
this.setState({ [whatState]: value })
}
render() {
return (
<View>
<TextInput
value={this.state.username}
onChangeText={(text)=>{toggleSetState(username, text)}
/>
<TextInput
value={this.state.password}
onChangeText={(text)=>{toggleSetState(password, text)}
/>
</View>
);
}
}
中的上述代码等效于什么?
我在Flutter
中尝试过此方法,但似乎不起作用
Flutter
答案 0 :(得分:0)
setState(() { _myState = newValue });
_myState为变量
答案 1 :(得分:0)
您只需要创建一个变量来保存值。我很困惑为什么不修改短暂状态时调用setState
以下是一些有用的文档 https://flutter.dev/docs/development/data-and-backend/state-mgmt/ephemeral-vs-app
Lat Pulldowns
Squats
Lat Pulldowns
Squats
Reverse Lunges
答案 2 :(得分:0)
经过研究和尝试,我可以使用以下代码实现我想要的:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim BarCode As String
Dim LastRowA As Long, LastRowC As Long, i As Long, Times As Long
Dim arr As Variant
'Let us assume that:
'1. All bar codes appears in column A
'2. The Selected bar code are in cell B2
'3. And the results are in column C
With ThisWorkbook.Worksheets("Sheet1")
If Not Intersect(Target, .Range("B2")) Is Nothing And Target.Count = 1 Then '<- Check if there is any change in cell B2
LastRowC = .Cells(.Rows.Count, "C").End(xlUp).Row
Application.EnableEvents = False
If LastRowC > 1 Then
.Range("C2:C" & LastRowC).Clear '<- If there are data in the results field clear them
End If
BarCode = Target.Value '<- Get the code imported
LastRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
arr = .Range("A2:A" & LastRowA) '<- Create an array with all the bar codes
For i = LBound(arr) To UBound(arr) '<- Loop codes
Debug.Print arr(i, 1)
If arr(i, 1) = BarCode Then
Times = Times + 1
If Times > 1 Then
LastRowC = .Cells(.Rows.Count, "C").End(xlUp).Row
.Range("C" & LastRowC + 1).Value = arr(i, 1)
End If
Else
LastRowC = .Cells(.Rows.Count, "C").End(xlUp).Row
.Range("C" & LastRowC + 1).Value = arr(i, 1)
End If
Next i
Application.EnableEvents = True
End If
End With
End Sub