W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
它揭示了如何將本地 ToastAndroid 模塊作為一個 JS 模塊。它有一個名為 showText
的函數(shù),其擁有的參數(shù)如下所示:
字符串消息:將文本傳遞給 toast 的字符串
int 持續(xù)期:toast 的持續(xù)期??赡苁?span id="m2mmcuu" class="Apple-converted-space"> ToastAndroid.SHORT
或 ToastAndroid.LONG
static show(message: string, duration: number)
SHORT: MemberExpression
LONG: MemberExpression
'use strict'; var React = require('react-native'); var { StyleSheet, Text, ToastAndroid, TouchableWithoutFeedback } = React; var UIExplorerBlock = require('UIExplorerBlock'); var UIExplorerPage = require('UIExplorerPage'); var ToastExample = React.createClass({ statics: { title: 'Toast Example', description: 'Toast Example', }, getInitialState: function() { return {}; }, render: function() { return ( <UIExplorerPage title="ToastAndroid"> <UIExplorerBlock title="Simple toast"> <TouchableWithoutFeedback onPress={() => ToastAndroid.show('This is a toast with short duration', ToastAndroid.SHORT)}> <Text style={styles.text}>Click me.</Text> </TouchableWithoutFeedback> </UIExplorerBlock> <UIExplorerBlock title="Toast with long duration"> <TouchableWithoutFeedback onPress={() => ToastAndroid.show('This is a toast with long duration', ToastAndroid.LONG)}> <Text style={styles.text}>Click me too.</Text> </TouchableWithoutFeedback> </UIExplorerBlock> </UIExplorerPage> ); }, }); var styles = StyleSheet.create({ text: { color: 'black', }, }); module.exports = ToastExample;
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: