1.1.9 • Published 2 years ago

react-native-dev-sdk v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-dev-sdk

react-native-dev-sdk

封装大部业务中常用组件,方法、方便项目中适用

安装依赖使用,安装需要将 dev 嵌入项目.

  npm i @react-native-async-storage/async-storage @react-navigation/native axios react-native-root-toast @react-navigation/native-stack @react-navigation/bottom-tabs react-native-gesture-handler react-native-safe-area-context react-native-screens validator react-native-svg axios --save

在项目 ios 目录下,执行 pod isntall

cd ios && pod install

使用

// px2dp
import { Toast, px2dp } from 'react-native-dev-sdk';

const styles = StyleSheet.create({
  container: {
    backgroundColor: 'red',
    width: px2dp(30),
    height: px2dp(30),
  },
});

return (
  <View style={styles.container}>
    <Text>hello app</Text>
    <Toast />
  </View>
);

Storage

import { StorageTools } from 'react-native-dev-sdk';

// 设置缓存
await StorageTools.setStorage('storage', 'hello');

// 获取缓存
await StorageTools.getStorage('storage');

Toast

import { RootToast } from 'react-native-dev-sdk';

// 显示toast
RootToast.showToast(optoins);

// options
options = {
  position,
  msg,
  duration,
  animation,
  shadow,
  backgroundColor,
  containerStyle,
  onHidden,
  onPress,
  onShow,
  delay,
};

axios封装

import { get } from 'react-native-sdk-dev';

// 发送get请求
const request = async = (url) => {
  await get(url)
}

// 发送post请求
const postRes = async = (url, data) => {
  await post(url, data)
}

// 编辑资料
const putRes = async (url, data) => {
  await post(url, data)
}

// 删除资料
const delRes = async (url) => {
  await del(url)
}