// App.js
import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import { faker } from '@faker-js/faker';
const App = () => {
const [name, setName] = useState('');
const generateName = () => {
setName(faker.name.findName());
};
return (
<View style={styles.container}>
<Text style={styles.header}>Random Name Generator</Text>
<Text style={styles.name}>{name}</Text>
<Button title="Generate Name" onPress={generateName} />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
header: {
fontSize: 24,
marginBottom: 20,
},
name: {
fontSize: 32,
marginBottom: 20,
},
});
export default App;const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
header: {
fontSize: 24,
marginBottom: 20,
},
name: {
fontSize: 32,
marginBottom: 20,
},
});
export default App;const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
header: {
fontSize: 24,
marginBottom: 20,
},
name: {
fontSize: 32,
marginBottom: 20,
},
});
export default App;const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
header: {
fontSize: 24,
marginBottom: 20,
},
name: {
fontSize: 32,
marginBottom: 20,
},
});
export default App;const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
header: {
fontSize: 24,
marginBottom: 20,
},
name: {
fontSize: 32,
marginBottom: 20,
},
});
export default App;
10. 基于手机APP开发实例--随机名生成器
原创mb64cc5144d532c ©著作权
©著作权归作者所有:来自51CTO博客作者mb64cc5144d532c的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
游戏编程脚本:随机名称生成器(scala)
import scala.util.Randomdef roll = { val first = Array( &nbs
职场 array 休闲 random scala