在react-native中使用native-base创建表单时出错

时间:2019-02-13 00:22:08

标签: react-native native-base

在react-native中使用native-base创建表单时出错:

  

错误:捆绑失败:错误:尝试解析模块时   来自文件的native-base   /Users/Ife/react_native/selfCare/app/components/Login/index.js,   包   /Users/Ife/react_native/selfCare/node_modules/native-base/package.json   已成功找到。但是,此程序包本身指定了一个   main个无法解析的模块字段   (/Users/Ife/react_native/selfCare/node_modules/native-base/dist/src/index.js。   实际上,这些文件都不存在:

在网上发现了类似的错误,说要从node_module / native-base中删除“ build folder”,但找不到该文件。请帮助

import React, { Component } from 'react';
// import { View, Text, TextInput, Button, Alert } from 'react-native';
import { Container, Header, Content, Form, Item, Input, Label, Button} from 
'native-base';

class Login extends Component {
  constructor(props) {
    super(props);
    this.state = {
        email:"",
        password:""
    };
  }
  static navigationOption = {
      header: null
  }

  checkLogin(){
      console.log("Logging in...")
  }
  render() {
return (
  // <View>
  //   <Text> Login </Text>

  //   <Text>Email:</Text>
  //   <TextInput placeholder='email' onChangeText={text => this.setState({username: text})}/>
  //   <Text>Password:</Text>
  //   <TextInput placeholder='password' secureTextEntry={true} onChangeText={text => this.setState({password: text})}/>
  //   <Button
  //       title='Login'
  //       onPress={_ => this.checkLogin()}
  //   />
  // </View>

  <Container>
    <Content>
      <Form>
        <Item fixedLabel>
          <Label>Email</Label>
          <Input placeholder='email' onChangeText={text => this.setState({email: text})}/>
        </Item>

        <Item fixedLabel last>
          <Label>Password</Label>
          <Input placeholder='password' secureTextEntry={true} onChangeText={text => this.setState({password: text})}/>
        </Item>

        <Button
          title='Login'
          onPress={_ => this.checkLogin()}
        />
      </Form>
    </Content>
  </Container>
);
}
}

export default Login;

0 个答案:

没有答案