在React Native中开发鸿组件(这里指的是鸿蒙(HarmonyOS)组件),你需要了解鸿蒙开发的基础以及如何在React Native项目中集成鸿蒙应用。鸿蒙OS是由华为开发的一个分布式操作
本文介绍了在React Native中开发鸿蒙(HarmonyOS)组件的两种主要方法:通过WebView加载鸿蒙应用网页版,或使用Native Modules桥接原生功能。文章首先概述了鸿蒙开发的基础知识,包括DevEco Studio工具和SDK配置,然后详细说明了集成方案的具体实现步骤。此外,还提供了一个"植物养护智能助手"的React Native开发实例,涵盖项目初始
在React Native中开发鸿组件(这里指的是鸿蒙(HarmonyOS)组件),你需要了解鸿蒙开发的基础以及如何在React Native项目中集成鸿蒙应用。鸿蒙OS是由华为开发的一个分布式操作系统,主要用于其智能设备,如手机、平板、智能手表等。
- 了解鸿蒙开发基础
首先,你需要熟悉鸿蒙OS的开发环境设置和基本开发流程。这包括:
- 开发工具:使用DevEco Studio作为开发IDE。
- SDK:下载并安装HarmonyOS SDK。
- 语言与框架:主要使用Java/Kotlin进行应用开发,但也可以通过C/C++扩展功能。
- 在React Native中集成鸿蒙应用
React Native本身主要用于Harmony和Harmony平台的开发,但你可以通过以下几种方式将鸿蒙应用集成到React Native项目中:
A. 使用WebView
一种简单的方法是使用WebView来加载鸿蒙应用的网页版或通过一个WebView桥接本地代码与鸿蒙应用。
-
在React Native中添加WebView:
npm install react-native-webview -
使用WebView加载鸿蒙应用的URL:
import React from 'react'; import { WebView } from 'react-native-webview'; const HarmonyApp = () => { return ( <WebView source={{ uri: 'https://your-harmony-app-url.com' }} style={{ flex: 1 }} /> ); }; export default HarmonyApp;
B. 使用Native Modules
创建一个Native Module来桥接React Native和鸿蒙原生应用。
-
在DevEco Studio中创建一个鸿蒙应用。
-
开发Native Module:创建一个Java/Kotlin模块,在其中实现与鸿蒙应用交互的逻辑。
-
在React Native中调用Native Module:使用
react-native-bridge或其他桥接库来调用鸿蒙原生模块。例如,使用
react-native-bridge:npm install react-native-bridge然后在JavaScript中调用:
import { NativeModules } from 'react-native'; const { HarmonyModule } = NativeModules;
C. 使用Deep Linking或Intent传递数据
如果你的鸿蒙应用支持Deep Linking或Intent传递数据,你可以在React Native中处理这些链接或Intent,并据此与鸿蒙应用交互。
- 职业发展规划和开发代码详情
对于职业发展规划,你可以考虑以下步骤:
- 学习鸿蒙开发:深入学习鸿蒙OS的APIs和开发工具。
- 实践项目:在项目中实践鸿蒙应用的开发与集成。
- 优化集成方案:不断优化React Native与鸿蒙应用的集成方案,提高用户体验和性能。
- 持续学习:关注鸿蒙OS的最新动态和更新,持续学习新技术和新特性。
- 分享和交流:参与开源项目,分享你的经验,与其他开发者交流。
通过这些步骤,你可以有效地在React Native项目中开发并集成鸿蒙组件,同时规划你的职业发展路径。
开发一个名为“植物养护智能助手”的React Native应用,涉及到多个技术层面,包括前端UI设计、后端数据处理以及可能的硬件接口(例如传感器数据采集)。下面,我将提供一个基本的开发指南和代码示例,帮助你开始这个项目。
- 环境准备
首先,确保你的开发环境已经安装了Node.js和React Native。你可以通过以下步骤安装React Native环境:
安装Node.js (如果尚未安装)
安装React Native CLI
npm install -g react-native-cli
创建一个新的React Native项目
react-native init PlantCareAssistant
进入项目目录
cd PlantCareAssistant
- 安装依赖
为了简化开发,可以使用一些现成的库来帮助处理植物养护相关的功能,例如使用react-native-vector-icons来添加图标、react-native-camera来处理图像识别等。
安装图标库
npm install react-native-vector-icons
安装相机库(可选,根据需求)
npm install react-native-camera
- 项目结构规划
创建一个基本的项目结构,例如:
PlantCareAssistant/
|-- Harmony/
|-- Harmony/
|-- src/
|-- components/
|-- screens/
|-- HomeScreen.js
|-- CareTipsScreen.js
|-- App.js
|-- package.json
- 开发界面组件
HomeScreen.js
import React from 'react';
import { View, Text, StyleSheet, Button } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome'; // 假设使用FontAwesome图标库
const HomeScreen = ({ navigation }) => {
return (
<View style={styles.container}>
<Text style={styles.title}>植物养护智能助手</Text>
<Button title="查看养护建议" onPress={() => navigation.navigate('CareTips')} />
<Icon name="leaf" size={50} color="green" /> {/* 显示一个叶子图标 */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 24,
marginBottom: 20,
},
});
export default HomeScreen;
CareTipsScreen.js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome'; // 使用相同图标库
const CareTipsScreen = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>养护建议</Text>
<Text>请每天给植物浇水。</Text> {/* 示例文本 */}
<Icon name="info-circle" size={30} color="blue" /> {/* 信息图标 */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 24,
marginBottom: 20,
},
});
export default CareTipsScreen;
- 导航设置(使用React Navigation)
安装React Navigation:
npm install @react-navigation/native @react-navigation/stack react-native-screens react-native-safe-area-context @react-navigation/native-stack @react-navigation/stack @react-navigation/bottom-tabs @react-navigation/material-top-tabs @react-navigation/material-bottom-tabs @react-navigation/drawer @react-navigation/elements @react-navigation/routers @react-navigation/web react-native-tab-view react-native-pager-view react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context react-native-svg expo @expo/vector-icons expo-linear-gradient expo-constants expo-linking --save` 确保所有依赖都正确安装。`npm install`。`npx pod-install
真实演示案例代码:
// app.tsx
import React, { useState } from 'react';
import { SafeAreaView, View, Text, StyleSheet, TouchableOpacity, ScrollView, Dimensions, Alert, FlatList } from 'react-native';
// 图标库
const ICONS = {
home: '🏠',
search: '🔍',
filter: '⚙️',
favorite: '❤️',
map: '🗺️',
phone: '📞',
chat: '💬',
back: '◀️',
};
const { width, height } = Dimensions.get('window');
// 房源类型
type Property = {
id: string;
title: string;
address: string;
price: number;
area: number;
bedrooms: number;
bathrooms: number;
features: string[];
images: string[];
isFavorite: boolean;
distance: string;
landlord: string;
rating: number;
description: string;
facilities: string[];
leaseTerms: string[];
};
// 主页面组件
const RentalApp: React.FC = () => {
const [properties] = useState<Property[]>([
{
id: '1',
title: '温馨两居室,采光充足',
address: '朝阳区建国门外大街',
price: 4500,
area: 75,
bedrooms: 2,
bathrooms: 1,
features: ['精装修', '家电齐全', '近地铁'],
images: [],
isFavorite: true,
distance: '500m',
landlord: '张先生',
rating: 4.8,
description: '这套房子位于朝阳区核心地段,交通便利,周边配套齐全。房屋精装修,家电家具齐全,拎包入住。小区环境优美,物业管理完善。',
facilities: ['WiFi', '空调', '洗衣机', '冰箱', '电视', '热水器', '燃气灶'],
leaseTerms: ['押一付三', '禁止养宠物', '限住两人', '水电燃气自理']
},
{
id: '2',
title: '现代化公寓,交通便利',
address: '海淀区中关村大街',
price: 5200,
area: 85,
bedrooms: 2,
bathrooms: 1,
features: ['拎包入住', '24h物业', '停车位'],
images: [],
isFavorite: false,
distance: '800m',
landlord: '李女士',
rating: 4.6,
description: '位于中关村核心区域,紧邻地铁站,通勤方便。房屋现代化装修,配备全套家电家具,适合年轻白领居住。',
facilities: ['WiFi', '空调', '洗衣机', '冰箱', '电视', '微波炉', '电磁炉'],
leaseTerms: ['押一付三', '可养宠物', '不限人数', '包物业费']
},
{
id: '3',
title: '舒适一居室,安静宜居',
address: '西城区金融街',
price: 3800,
area: 55,
bedrooms: 1,
bathrooms: 1,
features: ['精装修', '家具齐全', '朝南'],
images: [],
isFavorite: false,
distance: '1.2km',
landlord: '王先生',
rating: 4.9,
description: '位于金融街附近,环境安静,适合居住。房间宽敞明亮,采光极佳。周边有多个超市、餐厅和医院,生活便利。',
facilities: ['WiFi', '空调', '洗衣机', '冰箱', '电视', '书桌', '衣柜'],
leaseTerms: ['押一付三', '禁止养宠物', '限住一人', '水电燃气自理']
},
{
id: '4',
title: '豪华三居室,视野开阔',
address: '丰台区丽泽商务区',
price: 6800,
area: 120,
bedrooms: 3,
bathrooms: 2,
features: ['精装修', '家电齐全', '电梯房'],
images: [],
isFavorite: true,
distance: '300m',
landlord: '刘女士',
rating: 4.7,
description: '高层住宅,视野开阔,可俯瞰城市美景。三室两厅格局,空间宽敞,适合家庭居住。小区绿化率高,环境优美。',
facilities: ['WiFi', '空调', '洗衣机', '冰箱', '电视', '沙发', '餐桌', '厨具'],
leaseTerms: ['押一付三', '可养宠物', '限住四人', '水电燃气自理']
}
]);
const [selectedProperty, setSelectedProperty] = useState<Property | null>(null);
const [activeTab, setActiveTab] = useState<'list' | 'favorites' | 'profile'>('list');
const toggleFavorite = (propertyId: string) => {
Alert.alert('收藏', `房源已${properties.find(p => p.id === propertyId)?.isFavorite ? '取消收藏' : '收藏'}`);
};
const contactLandlord = (landlordName: string) => {
Alert.alert('联系房东', `正在联系房东: ${landlordName}`, [
{ text: '电话', onPress: () => Alert.alert('拨打电话', '正在拨打...') },
{ text: '聊天', onPress: () => Alert.alert('聊天', '打开聊天界面') },
{ text: '取消', style: 'cancel' }
]);
};
const goBackToList = () => {
setSelectedProperty = null;
};
const renderPropertyItem = ({ item }: { item: Property }) => (
<TouchableOpacity
style={styles.propertyCard}
onPress={() => setSelectedProperty(item)}
>
<View style={styles.propertyImage}>
<Text style={styles.propertyImageText}>🏠</Text>
</div>
<View style={styles.propertyInfo}>
<View style={styles.propertyHeader}>
<Text style={styles.propertyTitle}>{item.title}</Text>
<TouchableOpacity onPress={() => toggleFavorite(item.id)}>
<Text style={[styles.favoriteIcon, item.isFavorite && styles.favoriteActive]}>
{item.isFavorite ? ICONS.favorite : '♡'}
</Text>
</TouchableOpacity>
</div>
<View style={styles.addressRow}>
<Text style={styles.locationIcon}>📍</Text>
<Text style={styles.propertyAddress}>{item.address}</Text>
<Text style={styles.distance}>{item.distance}</Text>
</div>
<View style={styles.propertyDetails}>
<Text style={styles.bedrooms}>{item.bedrooms}室{item.bathrooms}卫</Text>
<Text style={styles.area}>{item.area}㎡</Text>
<Text style={styles.rating}>★ {item.rating}</Text>
</div>
<View style={styles.featuresContainer}>
{item.features.map((feature, index) => (
<View key={index} style={styles.featureTag}>
<Text style={styles.featureText}>{feature}</Text>
</View>
))}
</div>
<View style={styles.propertyFooter}>
<Text style={styles.propertyPrice}>¥{item.price}<Text style={styles.priceUnit}>/月</Text></Text>
<TouchableOpacity
style={styles.contactButton}
onPress={() => contactLandlord(item.landlord)}
>
<Text style={styles.contactButtonText}>联系</Text>
</TouchableOpacity>
</div>
</div>
</TouchableOpacity>
);
const renderPropertyDetail = (property: Property) => (
<ScrollView style={styles.detailContainer}>
<View style={styles.detailImage}>
<Text style={styles.detailImageText}>🏠</Text>
</div>
<View style={styles.detailContent}>
<View style={styles.detailHeader}>
<TouchableOpacity onPress={() => setSelectedProperty(null)} style={styles.backButton}>
<Text style={styles.backIcon}>{ICONS.back}</Text>
</TouchableOpacity>
<Text style={styles.detailTitle}>{property.title}</Text>
<TouchableOpacity onPress={() => toggleFavorite(property.id)}>
<Text style={[styles.detailFavoriteIcon, property.isFavorite && styles.favoriteActive]}>
{property.isFavorite ? ICONS.favorite : '♡'}
</Text>
</TouchableOpacity>
</div>
<View style={styles.detailPriceSection}>
<Text style={styles.detailPrice}>¥{property.price}<Text style={styles.detailPriceUnit}>/月</Text></Text>
<Text style={styles.detailAddress}>{property.address} | {property.distance}</Text>
</View>
<View style={styles.detailFeatures}>
<View style={styles.detailFeatureItem}>
<Text style={styles.detailFeatureValue}>{property.bedrooms}室{property.bathrooms}卫</Text>
<Text style={styles.detailFeatureLabel}>户型</Text>
</View>
<View style={styles.detailFeatureItem}>
<Text style={styles.detailFeatureValue}>{property.area}㎡</Text>
<Text style={styles.detailFeatureLabel}>面积</Text>
</View>
<View style={styles.detailFeatureItem}>
<Text style={styles.detailFeatureValue}>★ {property.rating}</Text>
<Text style={styles.detailFeatureLabel}>评分</Text>
</View>
</div>
<View style={styles.detailSection}>
<Text style={styles.detailSectionTitle}>房源描述</Text>
<Text style={styles.detailDescription}>{property.description}</Text>
</div>
<View style={styles.detailSection}>
<Text style={styles.detailSectionTitle}>房屋设施</Text>
<View style={styles.facilitiesContainer}>
{property.facilities.map((facility, index) => (
<View key={index} style={styles.facilityItem}>
<Text style={styles.facilityText}>{facility}</Text>
</View>
))}
</View>
</View>
<View style={styles.detailSection}>
<Text style={styles.detailSectionTitle}>租赁条款</Text>
<View style={styles.leaseTermsContainer}>
{property.leaseTerms.map((term, index) => (
<View key={index} style={styles.leaseTermItem}>
<Text style={styles.leaseTermText}>• {term}</Text>
</View>
))}
</View>
</div>
<View style={styles.detailSection}>
<Text style={styles.detailSectionTitle}>房东信息</Text>
<View style={styles.landlordInfo}>
<View style={styles.landlordAvatar}>
<Text style={styles.landlordAvatarText}>👤</Text>
</div>
<View style={styles.landlordDetails}>
<Text style={styles.landlordName}>{property.landlord}</Text>
<Text style={styles.landlordRating}>房东评分: ★ {property.rating}</Text>
</div>
</div>
</View>
<View style={styles.detailActions}>
<TouchableOpacity
style={styles.detailCallButton}
onPress={() => contactLandlord(property.landlord)}
>
<Text style={styles.detailCallButtonText}>📞 联系房东</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.detailChatButton}
onPress={() => Alert.alert('聊天', '打开聊天界面')}
>
<Text style={styles.detailChatButtonText}>💬 在线咨询</Text>
</TouchableOpacity>
</div>
</div>
</ScrollView>
);
return (
<SafeAreaView style={styles.container}>
{/* 头部 */}
<View style={styles.header}>
<View style={styles.searchContainer}>
<Text style={styles.searchIcon}>{ICONS.search}</Text>
<Text style={styles.searchPlaceholder}>搜索区域或地标</Text>
</div>
<TouchableOpacity style={styles.filterButton}>
<Text style={styles.filterIcon}>{ICONS.filter}</Text>
</TouchableOpacity>
</View>
{selectedProperty ? (
renderPropertyDetail(selectedProperty)
) : (
<ScrollView style={styles.content}>
<Text style={styles.sectionTitle}>推荐房源</Text>
<FlatList
data={properties}
renderItem={renderPropertyItem}
keyExtractor={item => item.id}
showsVerticalScrollIndicator={false}
/>
</ScrollView>
)}
{/* 底部导航 */}
<View style={styles.bottomNav}>
<TouchableOpacity
style={styles.navItem}
onPress={() => setActiveTab('list')}
>
<Text style={[styles.navIcon, activeTab === 'list' && styles.activeNavIcon]}>{ICONS.home}</Text>
<Text style={[styles.navText, activeTab === 'list' && styles.activeNavText]}>首页</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.navItem}
onPress={() => setActiveTab('favorites')}
>
<Text style={[styles.navIcon, activeTab === 'favorites' && styles.activeNavIcon]}>{ICONS.favorite}</Text>
<Text style={[styles.navText, activeTab === 'favorites' && styles.activeNavText]}>收藏</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.navItem}
onPress={() => setActiveTab('profile')}
>
<Text style={[styles.navIcon, activeTab === 'profile' && styles.activeNavIcon]}>{ICONS.phone}</Text>
<Text style={[styles.navText, activeTab === 'profile' && styles.activeNavText]}>联系</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f8fafc',
},
header: {
flexDirection: 'row',
alignItems: 'center',
padding: 16,
backgroundColor: '#ffffff',
borderBottomWidth: 1,
borderBottomColor: '#e2e8f0',
},
searchContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#f1f5f9',
borderRadius: 20,
paddingVertical: 10,
paddingHorizontal: 16,
},
searchIcon: {
fontSize: 18,
color: '#64748b',
marginRight: 12,
},
searchPlaceholder: {
fontSize: 14,
color: '#94a3b8',
flex: 1,
},
filterButton: {
width: 40,
height: 40,
borderRadius: 20,
backgroundColor: '#f1f5f9',
alignItems: 'center',
justifyContent: 'center',
marginLeft: 12,
},
filterIcon: {
fontSize: 18,
color: '#64748b',
},
content: {
flex: 1,
padding: 16,
},
sectionTitle: {
fontSize: 18,
fontWeight: 'bold',
color: '#1e293b',
marginVertical: 12,
},
propertyCard: {
backgroundColor: '#ffffff',
borderRadius: 12,
marginBottom: 16,
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 4,
},
propertyImage: {
width: '100%',
height: height * 0.25,
backgroundColor: '#e2e8f0',
borderTopLeftRadius: 12,
borderTopRightRadius: 12,
alignItems: 'center',
justifyContent: 'center',
},
propertyImageText: {
fontSize: 48,
},
propertyInfo: {
padding: 16,
},
propertyHeader: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'flex-start',
marginBottom: 8,
},
propertyTitle: {
fontSize: 16,
fontWeight: '600',
color: '#1e293b',
flex: 1,
marginRight: 8,
},
favoriteIcon: {
fontSize: 24,
color: '#cbd5e1',
},
favoriteActive: {
color: '#ef4444',
},
addressRow: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8,
},
locationIcon: {
fontSize: 14,
color: '#64748b',
marginRight: 6,
},
propertyAddress: {
fontSize: 14,
color: '#64748b',
flex: 1,
},
distance: {
fontSize: 12,
color: '#f59e0b',
backgroundColor: '#fef3c7',
paddingHorizontal: 6,
paddingVertical: 2,
borderRadius: 8,
},
propertyDetails: {
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 12,
},
bedrooms: {
fontSize: 12,
color: '#64748b',
},
area: {
fontSize: 12,
color: '#64748b',
},
rating: {
fontSize: 12,
color: '#f59e0b',
},
featuresContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
marginBottom: 12,
},
featureTag: {
backgroundColor: '#dbeafe',
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 12,
marginRight: 6,
marginBottom: 6,
},
featureText: {
fontSize: 11,
color: '#3b82f6',
},
propertyFooter: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
propertyPrice: {
fontSize: 20,
fontWeight: 'bold',
color: '#ef4444',
},
priceUnit: {
fontSize: 12,
color: '#64748b',
},
contactButton: {
backgroundColor: '#3b82f6',
paddingHorizontal: 16,
paddingVertical: 8,
borderRadius: 20,
},
contactButtonText: {
color: '#ffffff',
fontWeight: '500',
},
detailContainer: {
flex: 1,
backgroundColor: '#ffffff',
},
detailImage: {
width: '100%',
height: height * 0.3,
backgroundColor: '#e2e8f0',
alignItems: 'center',
justifyContent: 'center',
},
detailImageText: {
fontSize: 64,
},
detailContent: {
flex: 1,
padding: 16,
},
detailHeader: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 16,
},
backButton: {
padding: 8,
},
backIcon: {
fontSize: 20,
color: '#64748b',
},
detailTitle: {
fontSize: 18,
fontWeight: 'bold',
color: '#1e293b',
flex: 1,
textAlign: 'center',
marginHorizontal: 32,
},
detailFavoriteIcon: {
fontSize: 24,
color: '#cbd5e1',
},
detailPriceSection: {
marginBottom: 16,
},
detailPrice: {
fontSize: 28,
fontWeight: 'bold',
color: '#ef4444',
marginBottom: 4,
},
detailPriceUnit: {
fontSize: 14,
color: '#64748b',
},
detailAddress: {
fontSize: 14,
color: '#64748b',
},
detailFeatures: {
flexDirection: 'row',
justifyContent: 'space-around',
backgroundColor: '#f8fafc',
paddingVertical: 16,
borderRadius: 12,
marginBottom: 16,
},
detailFeatureItem: {
alignItems: 'center',
},
detailFeatureValue: {
fontSize: 16,
fontWeight: 'bold',
color: '#1e293b',
marginBottom: 4,
},
detailFeatureLabel: {
fontSize: 12,
color: '#64748b',
},
detailSection: {
marginBottom: 20,
},
detailSectionTitle: {
fontSize: 16,
fontWeight: 'bold',
color: '#1e293b',
marginBottom: 12,
},
detailDescription: {
fontSize: 14,
color: '#64748b',
lineHeight: 20,
},
facilitiesContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
},
facilityItem: {
backgroundColor: '#f0fdf4',
paddingHorizontal: 12,
paddingVertical: 6,
borderRadius: 20,
marginRight: 8,
marginBottom: 8,
},
facilityText: {
fontSize: 12,
color: '#16a34a',
},
leaseTermsContainer: {},
leaseTermItem: {
marginBottom: 8,
},
leaseTermText: {
fontSize: 14,
color: '#64748b',
},
landlordInfo: {
flexDirection: 'row',
alignItems: 'center',
},
landlordAvatar: {
width: 50,
height: 50,
borderRadius: 25,
backgroundColor: '#dbeafe',
alignItems: 'center',
justifyContent: 'center',
marginRight: 12,
},
landlordAvatarText: {
fontSize: 24,
},
landlordDetails: {},
landlordName: {
fontSize: 16,
fontWeight: 'bold',
color: '#1e293b',
marginBottom: 4,
},
landlordRating: {
fontSize: 14,
color: '#f59e0b',
},
detailActions: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 20,
},
detailCallButton: {
flex: 1,
backgroundColor: '#3b82f6',
paddingVertical: 14,
borderRadius: 12,
marginRight: 8,
alignItems: 'center',
},
detailCallButtonText: {
color: '#ffffff',
fontWeight: 'bold',
fontSize: 16,
},
detailChatButton: {
flex: 1,
backgroundColor: '#10b981',
paddingVertical: 14,
borderRadius: 12,
marginLeft: 8,
alignItems: 'center',
},
detailChatButtonText: {
color: '#ffffff',
fontWeight: 'bold',
fontSize: 16,
},
bottomNav: {
flexDirection: 'row',
justifyContent: 'space-around',
backgroundColor: '#ffffff',
borderTopWidth: 1,
borderTopColor: '#e2e8f0',
paddingVertical: 12,
},
navItem: {
alignItems: 'center',
flex: 1,
},
navIcon: {
fontSize: 20,
color: '#94a3b8',
marginBottom: 4,
},
activeNavIcon: {
color: '#3b82f6',
},
navText: {
fontSize: 12,
color: '#94a3b8',
},
activeNavText: {
color: '#3b82f6',
fontWeight: '500',
},
});
export default RentalApp;

打包
接下来通过打包命令npn run harmony将reactNative的代码打包成为bundle,这样可以进行在开源鸿蒙OpenHarmony中进行使用。

打包之后再将打包后的鸿蒙OpenHarmony文件拷贝到鸿蒙的DevEco-Studio工程目录去:

最后运行效果图如下显示:
欢迎大家加入开源鸿蒙跨平台开发者社区,一起共建开源鸿蒙跨平台生态。
更多推荐



所有评论(0)