探索React Native HiApp:打造高效跨平台移动应用
warning:
这篇文章距离上次修改已过190天,其中的内容可能已经有所变动。
import React from 'react';
import {
View,
Text,
StyleSheet,
// 引入自定义的Button组件
Button,
} from '@hi-react-weapp/hi-react';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.title}>HiApp 示例程序</Text>
{/* 使用Button组件 */}
<Button title="点击我" onPress={this.handlePress} />
</View>
);
}
handlePress = () => {
// 处理按钮点击事件
console.log('按钮被点击了!');
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});
这段代码演示了如何在React Native中使用HiApp提供的Button组件。通过引入Button组件并在render方法中使用它,我们创建了一个具有按钮的简单用户界面,并且可以通过onPress属性来处理按钮点击事件。这个例子简单明了地展示了如何使用HiApp组件库中的组件,并且如何在React Native应用中构建用户界面。
评论已关闭