React Native Elements

https://reactnativeelements.com/

装包:

yarn add @rneui/themed @rneui/base
yarn add react-native-safe-area-context

 

按钮、加载中进度条 ,分割线:

import React, { useState, useRef, useEffect } from 'react'
import { View, TextInput, Text } from 'react-native'
import style from './src/static/style/index.js'
import Api from './src/api'
import { Icon } from './src/component/light'
import { Divider, LinearProgress, Button } from '@rneui/themed'

export default function App() {
  const [username, setUsername] = useState('admin')
  const [password, setPasswork] = useState('123456')
  const [visible, setVisible] = useState(false)
  const [isLoading, setIsLoading] = useState(false)
  const usernameEl = useRef(null)

  const handleInput = (e) => {
    console.log(e)
    setUsername(e)
  }

  const handleLogin = () => {
    console.log(777, username, password)
    Api.light.getUserInfo().then((res) => {
      console.log(res)
    })
    setIsLoading(true)
    Api.light.login({ username, password }).then((res) => {
      console.log(res)
      setIsLoading(false)
    })
  }

  const handleVisilbe = () => {
    setVisible(!visible)
  }

  useEffect(() => {
    //usernameEl.current.focus()
    //console.log(666, usernameEl.current.isFocused())
  }, [])

  return (
    <View style={style.mLoginWrap}>
      <LinearProgress style={[style.mLoading, isLoading ? style.mLoadingActive : {}]} color="primary" />
      <View style={style.mLoginRow}>
        <TextInput
          style={style.mLoginInput}
          value={username}
          onChangeText={handleInput}
          // autoFocus
          ref={usernameEl}
        ></TextInput>
      </View>
      <View style={style.mLoginRow}>
        <TextInput
          style={style.mLoginInput}
          value={password}
          onChangeText={setPasswork}
          secureTextEntry={!visible}
        ></TextInput>
        <Icon
          name={visible ? 'show' : 'close'}
          size={40}
          color="#333"
          onPress={handleVisilbe}
          style={style.mLoginPasswordIcon}
        ></Icon>
      </View>
      <View style={style.mLoginRow}>
        <Button onPress={handleLogin} type="solid" title="登录"></Button>
      </View>
      <Divider></Divider>
      
    </View>
  )
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
React Native面试题可以包括以下几个方面: 1. React Native***应用的框架,基于React的思想和语法。它可以使用JavaScriptReact的开发方式来构建原生应用,具有快速开发、跨平台兼容、热加载、高性能等特点。 2. React NativeReact的区别是什么? React是用于构建Web应用的框架,而React Native是用于构建移动应用的框架。React Native可以使用React的开发方式来构建原生应用,而不需要使用WebView。 3. React Native中如何处理网络通信? 在React Native中,可以使用fetch函数进行网络通信。可以通过fetch发送HTTP请求,并通过Promise的方式处理返回结果。 4. React Native中如何进行导航管理? React Native提供了react-navigation库来进行导航管理。通过定义Stack Navigator、Tab Navigator等导航组件,可以方便地实现页面之间的跳转和导航。 5. React Native中如何处理数据状态管理? 在React Native中,可以使用Redux等状态管理库来统一管理应用的状态。Redux可以帮助我们管理应用的数据流,使得状态的变化可预测和可控。 6. 请介绍一下React Native的生命周期方法。 React Native中的生命周期方法与React的生命周期方法类似,包括componentDidMount、componentDidUpdate、componentWillUnmount等,用于在组件的不同生命周期阶段执行相应的操作。 7. React Native中如何进行布局和样式定义? React Native使用Flexbox布局来进行页面布局。可以使用StyleSheet来定义组件的样式,类似于CSS的样式定义方式。 8. 请介绍一下React Native中常用的第三方组件库。 在React Native中,有很多常用的第三方组件库可供选择,例如React Navigation、React Native ElementsReact Native Vector Icons等。这些组件库可以帮助开发者更方便地构建移动应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐同保

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值