我有以下问题,计数器变量的状态更改不会触发 Text 组件的重新组合。关于可能是什么问题的任何想法???
@Model
class CounterState(var counter:Int = 0)
@Composable
fun CounterView(counterState: CounterState){
Column {
Text(text= "${counterState.counter}",
style=(+typography()).body1)
Button(text ="Increment",
onClick = {counterState.counter++},
style = ContainedButtonStyle())
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
app {
CounterView(CounterState())
}
}
}