如何在 react-native 文本之后放置按钮?
How to put button just after text in react-native?
如何像下图一样在 react-native 的文本后面放置按钮?
例如,您可以使用 <TouchableOpacity></TouchableOpacity>
。您只需要将 <Text>-Tag
包裹在其中即可。
<TouchableOpacity> <Text> edit </Text> </TouchableOpacity>
TouchableOpacity 具有类似于 Button 的 OnPress 事件。
你可以试试https://www.npmjs.com/package/react-native-render-html#making-your-custom-component-block-or-inline
将编辑按钮设为 href link,您可以在 onLinkPress 属性上获取它的 onPress
您可以在 Text
组件中使用 onPress
属性。并使用嵌套 Text
你可以在这里试试:https://snack.expo.io/@vasylnahuliak/9a76b0
import React, { useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';
const App = () => {
const handleLinkPress = () => {
alert('link pressed')
}
return (
<View style={styles.container}>
<Text>
Short descriptopm for trainer: Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore.
<Text style={styles.link} onPress={handleLinkPress}> edit </Text>
</Text>
</View>
);
};
const styles = StyleSheet.create({
link: {
color: 'blue',
fontWeight: 'bold',
},
});
export default App;
如何像下图一样在 react-native 的文本后面放置按钮?
例如,您可以使用 <TouchableOpacity></TouchableOpacity>
。您只需要将 <Text>-Tag
包裹在其中即可。
<TouchableOpacity> <Text> edit </Text> </TouchableOpacity>
TouchableOpacity 具有类似于 Button 的 OnPress 事件。
你可以试试https://www.npmjs.com/package/react-native-render-html#making-your-custom-component-block-or-inline
将编辑按钮设为 href link,您可以在 onLinkPress 属性上获取它的 onPress
您可以在 Text
组件中使用 onPress
属性。并使用嵌套 Text
你可以在这里试试:https://snack.expo.io/@vasylnahuliak/9a76b0
import React, { useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';
const App = () => {
const handleLinkPress = () => {
alert('link pressed')
}
return (
<View style={styles.container}>
<Text>
Short descriptopm for trainer: Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore.
<Text style={styles.link} onPress={handleLinkPress}> edit </Text>
</Text>
</View>
);
};
const styles = StyleSheet.create({
link: {
color: 'blue',
fontWeight: 'bold',
},
});
export default App;