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)
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » ReactNative SDK 库之 react-native-dev-sdk
发表评论 取消回复