我正在嘗試建立一個(gè) TextInput 元件,該元件在鍵入某人的名字時(shí)具有自訂視圖。例如,如果名字是 John,它將搜尋該字串並添加視圖,其中包含 John 的個(gè)人資料圖像以及他的名字與文字內(nèi)聯(lián)。目前,當(dāng)我將視圖作為 TextInput 元件的子元件時(shí),不會(huì)顯示任何內(nèi)容。也就是說(shuō),只有文字組件的孩子確實(shí)會(huì)出現(xiàn)。
我嘗試在 TextInput 元件中渲染各種類(lèi)型的容器和元素,但以上所有內(nèi)容都沒(méi)有顯示在渲染中。
TextInput 中只能包含文字。我會(huì)嘗試將 Image 元件和 TextInput 元件包裝在行對(duì)齊視圖中。
<View style={{flexDirection: "row", width: "100%", borderWidth: 1}}> <Image style={{height: 30, width: 30}} source={require("./your/image.path")}/> <TextInput style={{width: "75%"}}/> </View>