reactjs - 我如何运行反应原生项目
问题描述
我写了这段代码,但它不起作用并且有错误
import React, {Component} from 'react';
import {Platform, StyleSheet, Text} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
它与其他代码一样无法正常工作,并且我的应用程序崩溃请帮我解决它
解决方案
在您的代码中,您忘记在第二行代码中的组件中导入 View,您应该这样编写:
import {Platform, StyleSheet, Text, View} from 'react-native';
推荐阅读
- jestjs - 方法“模拟”意味着在 1 个节点上运行。找到了 0 个。笑话/酶
- spring-boot - 将 Spring Boot Security SAML 与 Azure AD Gallery 应用程序集成为多租户
- ubuntu-18.04 - 无法在 Windows 10 上的 WSL2(Linux 2 的 Windows 子系统)内实例化 qemu-kvm VM
- android - 为此在 Android 5.1.1 中出现错误 - drawable.setAlpha(127);
- c++ - 使用字符串到对象的插入重载
- azure-aks - 如何在 Azure Kubernetes 服务 (AKS) 上升级 Hyperledger Fabric 联盟中的链代码
- django - 无法在我用于 Nginx 和 Supervisor 的部署时的 Django 应用聊天中连接到 WebSocket Nginx
- arrays - 如何使用 map 函数列出 React 中的数组?
- visual-c++ - 程序完成后,C++ 编写操作仍在进行中
- javascript - 为什么绘制的圆圈不显示在地图上?