我想添加一个image
到TextInput
. 像安卓Spannable
和IOS一样NSAttributedString
<Text>
<Text> Test </ Text>
<Image source = {myImage} />
</Text>
我得到了我想要的结果。
但是,它在 TextInput 中不可用。如果出现添加<Image>
或<Text>
到 TextInput
[Object object]
。
我怎样才能添加这个?
addImage = () => {
const { content } = this.state;
this.setState({
content: content + <Image source={this.myImage} />
})
}
<TextInput
ref={(c) => { this.input = c; }}
multiline
style={[styles.inputStyle, { height: inputHeight }]}
underlineColorAndroid="transparent"
placeholder="PlaceHolder"
placeholderTextColor="#BCBCBC"
value={content}
onChangeText={text => changeContent(text)}
onContentSizeChange={event => changeInputHeight(event)}
/>
<Button onPress={() => addImage()} />
相同的结果
<TextInput
ref={(c) => { this.input = c; }}
multiline
style={[styles.inputStyle, { height: inputHeight }]}
underlineColorAndroid="transparent"
placeholder="PlaceHolder"
placeholderTextColor="#BCBCBC"
value={content}
onChangeText={text => changeContent(text)}
onContentSizeChange={event => changeInputHeight(event)}
>
<Text>
{content}
</Text>
</TextInput
<Button onPress={() => addImage()} />
我想说的是介于表情符号等内容之间的图像。它不是固定在左侧或右侧的图像。
这是 React Native 错误 https://github.com/facebook/react-native/issues/18566