
reactnative
从0开始了解reactnative
晓果博客
You’ll never realize how strong you are until you have no other choice but to be strong<br>你永远都不会知道自己到底有多坚强,直到有一天你除了坚强别无选择。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
024.RN项目android打包
生成签名密钥$ keytool -genkeypair -v -storetype PKCS12 -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000推荐使用androidStudio创建,方便快捷设置 gradle 变量MYAPP_RELEASE_STORE_FILE=freeread.jksMYAPP_RELEASE_KEY_ALIAS=hu.原创 2022-04-22 16:12:50 · 2294 阅读 · 0 评论 -
023.解决启动白屏&&清除日志
引入插件yarn add react-native-splash-screenandroid配置在android/app/src/main/res/layout文件夹下创建启动页的XML文件launch_screen.xml并添加如下代码<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" andro原创 2022-04-22 16:06:23 · 682 阅读 · 0 评论 -
022.formik表单使用
导入yarn add formikyarn add yupyarn add -D @types/yupFormik 使用import { RootStackNavigation, RootStackParamList } from '@/navigator/index';import { pTd } from '@/utils/index';import { RouteProp } from '@react-navigation/native';import { Field, Fo.原创 2022-04-22 16:02:13 · 483 阅读 · 0 评论 -
021.全局loading设置
创建AppLoading组件import React, { PureComponent } from 'react';import { View, Text, StyleSheet, ActivityIndicator } from 'react-native';import { pTd, viewportWidth, viewportHeight } from '@/utils/index'/** * 全局加载中控件, * 一般用于网络等异步加载 */class AppLoadin..原创 2022-04-22 16:00:22 · 962 阅读 · 0 评论 -
020.视频播放
导入视频插件yarn add react-native-videoyarn add -D @types/react-native-videoyarn add react-native-video-controlscd ios / pod installhttps://github.com/react-native-video/react-native-video#controlshttps://github.com/itsnubix/react-native-video-controls#.原创 2022-04-22 15:57:46 · 435 阅读 · 0 评论 -
019.realm数据库升级更新
添加新字段升级数据库版本并迁移数据//deleteRealmIfMigrationNeeded 删库更新const realm = new Realm({ schema: [MyListen, TestRealm], schemaVersion: 2, deleteRealmIfMigrationNeeded: false, migration: (oldRealm, newRealm) => { if (oldRealm.schemaVersion <原创 2022-04-22 15:54:59 · 1862 阅读 · 0 评论 -
018:realm数据库使用
yarn add realm重新运行 yarn android / (cd ios 、pod install --verbose 、yarn ios)创建数据表import Realm from 'realm';/**定义数据表 */export const TestRealmTableName = 'TestRealm' //测试数据表/** * 建表 */const TestRealm = { name: TestRealmTableName,//表名 pri原创 2022-04-22 15:52:39 · 1628 阅读 · 0 评论 -
017:RN音频播放
导入yarn add react-native-soundyarn add @react-native-community/slider工具类sound.ts import Sound from 'react-native-sound'// 在静音模式下启用播放Sound.setCategory('Playback');let sound: Sound;const initPlayer = (filepath: string) => { return new ..原创 2022-04-22 15:49:54 · 774 阅读 · 0 评论 -
016:RN--屏幕适配
React Native 可以开发 ios 和 android 的 app,在开发过程中,势必会遇上屏幕适配(ios 好几种尺寸的屏幕以及android 各种尺寸的屏幕)的问题,下面介绍一种几行代码搞定 RN 适配的方法!屏幕适配的前置知识RN 中的尺寸单位为 dp,而设计稿中的单位为 px原理虽然单位不同,但是元素所占屏幕宽度的比例是相同的利用元素所占屏幕比例不变的特性,来将 px 转为 dp(这样实现屏幕适配的话,在不同尺寸的屏幕下,元素会等比放大或缩小)公式如下:设计稿元素宽度.转载 2022-04-22 15:47:11 · 509 阅读 · 0 评论 -
015:RN广播接收者使用&平台判断&android 吐司
RN广播接收者使用导入import { DeviceEventEmitter } from 'react-native';发送广播DeviceEventEmitter.emit('HttpErrCode', { code: 300 })广播接收import { DeviceEventEmitter, EmitterSubscription} from 'react-native';class Home extends Component<IProps原创 2022-04-22 15:44:26 · 2312 阅读 · 0 评论 -
014:动态设置标题栏背景&&TabView使用
动态设置标题栏背景 // 关联dva const mapStateToProps = ({ album }: RootState) => { return { datas: album.albumDatas,//这里的home就是model中的namespace } } //这里需要connect对象 const connector = connect(mapStateToProps) //自动推.原创 2022-04-22 15:41:44 · 532 阅读 · 0 评论 -
013.图片模糊效果
引入yarn add @react-native-community/blurCould not find com.eightbitlab:blurview:1.6.3.allprojects { repositories { mavenCentral() mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binarie.原创 2022-04-22 15:33:23 · 484 阅读 · 0 评论 -
012.mac电脑运行yarn android,pod install报错
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ContMAC(OSX)升到 11.0.1 bigsur 后 android 打包报错 Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contai原创 2022-04-22 15:29:30 · 735 阅读 · 0 评论 -
011:拖拽组件的使用
安装yarn add react-native-drag-sort导入//拖拽组件import { DragSortableView } from 'react-native-drag-sort';使用 {/* 拖拽组件 */} <DragSortableView dataSource={myCategorys}//数据源 fixedIt.原创 2022-04-22 15:27:08 · 882 阅读 · 0 评论 -
010.本地持久库
https://github.com/sunnylqm/react-native-storage安装@react-native-community/async-storageyarn add @react-native-community/async-storageyarn add react-native-storage创建storage.ts操作库import AsyncStorage from "@react-native-community/async-storage";im原创 2022-04-22 15:21:26 · 310 阅读 · 0 评论 -
009.列表实现(上拉加载,下拉刷新)
效果目录结构 componts :组件 emptylist : 空列表占位 footerlist:列表底部显示 loadinglist:数据加载中页面占位 touchable:点击事件处理config:公共配置 contant :分页参数 dva:数据仓库 request:网络请求models:数据处理 data:公共参数 home:首页接口数据处理 index:数据导出统一入口pages:页面处理 ······ home:首页 components:组件.原创 2022-04-22 15:18:57 · 721 阅读 · 0 评论 -
008.dva中使用网络请求
安装axiosyarn add axios封装request.jsimport axios from 'axios'import Config from "react-native-config";const service = axios.create({ baseURL: Config.API_URL, timeout: 30000 // request timeout})service.interceptors.request.use( conf.原创 2022-04-22 15:07:01 · 478 阅读 · 0 评论 -
007.轮播图
效果安装yarn add react-native-snap-carousel yarn add @types/react-native-snap-carousel -D创建轮播图组件import React, { Component } from 'react';import SnapCarousel, { ParallaxImage, Pagination } from 'react-native-snap-carousel'import type { Additio.原创 2022-04-22 15:00:43 · 293 阅读 · 0 评论 -
006.集成Dva-core到react-native中
安装yarn add dva-core-ts react-reduxyarn add @types/react-redux -Dyarn add dva-loading-ts在models模块下配置 页面所需要的dva数据操作类(例如:home.ts)import { Model, Effect } from 'dva-core-ts'import { Reducer } from 'redux'type HomeState = { num: number}int.原创 2022-04-22 14:54:06 · 564 阅读 · 0 评论 -
005.react-navigation使用(二):配置字体图标&StatusBar状态栏设置
为导航栏配置字体图标yarn add react-native-svgyarn add react-native-iconfont-cli --dev在ios中需要安装依赖cd iospod install生成配置文件npx iconfont-init生成线上图标库修改iconfont.json{ "symbol_url": "http://at.alicdn.com/t/font_2515860_3i4n2umystp.js", "use_typ原创 2022-04-22 14:45:13 · 1687 阅读 · 0 评论 -
004.react-navigation使用(一):堆栈式导航器&底部标签导航器
文档地址https://reactnavigation.org/docs/getting-started/安装yarn add @react-navigation/nativeyarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-viewios无..原创 2022-04-22 14:33:48 · 2787 阅读 · 0 评论 -
003.绝对路径配置
安装依赖yarn add babel-plugin-module-resolver配置babel.config.jsmodule.exports = { presets: ['module:metro-react-native-babel-preset'], plugins:[ [ 'module-resolver', { root:['./src'], alias:{ '@/utils':'./s.原创 2022-04-22 14:21:03 · 436 阅读 · 0 评论 -
002.多环境配置
安装yarn add react-native-config创建.env文件API_URL=https://myapi.com在app.tsx中导入react-native-config 测试是否完成import Config from "react-native-config";<Text>{Config.API_URL}</Text>显示API_URL=https://myapi.com配置完毕ios无法自动连接需要配置cd ios .原创 2022-04-21 18:39:26 · 303 阅读 · 0 评论 -
001.ReactNative—项目初始化
创建TS模板项目npx react-native init AwesomeTSProject --template react-native-template-typescript转载 2022-04-21 18:29:04 · 277 阅读 · 0 评论