模板版本:v0.2.0
[!TIP] Github 地址
进入到工程目录并输入以下命令:
npm install react-native-easy-toast@2.3.0yarn add react-native-easy-toast@2.3.0下面的代码展示了这个库的基本使用场景:
import React, { Component } from "react";
import { Text, View, Button } from "react-native";
import {
Toast
} from "react-native-easy-toast";
export default class App extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View>
<Button title={'Press me'} onPress={()=>{
this.toast.show('hello world!',2000);
}}/>
<Toast ref={(toast) => this.toast = toast}/>
</View>
)
}
}
更多使用场景可查看 react-native-easy-toast 源库地址
在下述版本验证通过:
- RNOH:0.72.20; SDK:HarmonyOS NEXT Developer Preview2(B.0.73); IDE:DevEco Studio 5.0.3.200; ROM:2.0.0.58;
- RNOH:0.72.33; SDK:OpenHarmony 5.0.0.71(API Version 12 Release); IDE:DevEco Studio 5.0.3.900; ROM:NEXT.0.0.71;
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|---|---|---|---|---|---|
| style | Custom style toast | View.propTypes.style | no | All | yes |
| position | Custom toast position | PropTypes.oneOf(['top','center','bottom',]) | no | All | yes |
| positionValue | Custom toast position value | React.PropTypes.number | no | All | yes |
| fadeInDuration | Custom toast show duration | React.PropTypes.number | no | All | yes |
| fadeOutDuration | Custom toast close duration | React.PropTypes.number | no | All | yes |
| opacity | Custom toast opacity | React.PropTypes.number | no | All | yes |
| textStyle | Custom style text | View.propTypes.style | no | All | yes |
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|---|---|---|---|---|---|
| show | show a toast,unit is millisecond,and do callback | (text: string, duration: number, callback: function, onPress: function) | no | All | yes |
| close | start the close timer | - | no | All | yes |
本项目基于 MIT Licensed ,请自由地享受和参与开源。