跨境算力瓶颈频发,CXL内存池化如何破解AI出海落地难题
2026/4/29 1:20:27
varfruitListbyremember{mutableStateListOf("苹果","香蕉","橙子")}Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegateby 关键字是 Kotlin 的委托属性语法,它要求右侧的对象必须实现 getValue 和 setValue 函数
mutableStateListOf 函数返回的是MutableList<T>,这个类型本身不支持作为属性委托使用
varfruitList=remember{mutableStateListOf("苹果","香蕉","橙子")}对于 List / Map 类型的状态:总是使用 = 和mutableStateListOf()/mutableStateMapOf()
对于单个值类型的状态:使用 by 和mutableStateOf()
remember 的作用是在重组时保持状态,防止重新初始化