我可以有
val composeFunction = remember { mutableStateOf ({}) }
我可以有
val composeFF = @Composable { Text("ABC") }
val composeFunction = remember { mutableStateOf (composeFF) }
為什么我不能
val composeFunction = remember { mutableStateOf (@Composable { Text("ABC") }) }
它出錯了狀態
Internal Error occurred while analyzing this expression
(Please use the "
" icon in the bottom-right corner to report this error):
jar:file:/Applications/Android Studio.app/Contents/lib/platform-impl.jar!/general/error.svg
Type inference failed. Expected type mismatch: inferred type is @Composable () -> Unit but () -> Unit was expected
uj5u.com熱心網友回復:
您是否嘗試過指定型別?
val composeFunction = remember { mutableStateOf<@Composable () -> Unit> (@Composable { Text("ABC") }) }
看起來編譯器無法將普通函式推斷為帶有@Composable注釋的東西
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/511617.html
標籤:安卓科特林android-jetpack-compose
