【发布时间】:2020-01-15 20:13:19
【问题描述】:
我是 react native 的新手,并试图从组件文件夹中导入登录组件,但它显示错误 Click here to see screenshot
我用下面的代码试过了,我做错了什么
App.js
import React, { Component } from 'react';
import { Text, TextInput, View, Button, AppRegistry } from 'react-native';
import Login from './components/Login';
const styles = StyleSheet.create({
container: {
display:'flex',
justifyContent:'center',
alignItems:'center',
}
});
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Login />
</View>
);
}
}
登录.js
import React from 'react';
import { Text, View, StyleSheet, Image } from 'react-native';
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
render() {
return (
<View style={styles.container}>
<View style={{padding: 10, justifyContent:'center'}}>
<TextInput
style={{height: 40,borderBottomWidth:2,marginBottom:20}}
placeholder="Enter Mobile No."
onChangeText={(text) => this.setState({text})}
value=""
/>
<Button title="Sign in" style={{backgroundColor:'#3b5da8'}} />
</View>
</View>
);
}
【问题讨论】:
-
嗨 Lokesh,检查我的解决方案,如果有帮助,请告诉我。
-
可能与错误无关,但您在 Login.js 中缺少 TextInput 和 Button 的导入
标签: reactjs react-native import components expo