【发布时间】:2016-08-29 18:28:04
【问题描述】:
我正在尝试在 android 中开发本机模块以响应本机。 完全按照链接在 https://facebook.github.io/react-native/docs/native-modules-android.html#content
但它给了我错误
/ReactNativeJS: undefined is not an object (evaluating '_ToastAndroid2.default.show')
我已经实现了 ToastAndroid.js
'use strict';
/**
* This exposes the native ToastAndroid module as a JS module. This has a
* function 'show' which takes the following parameters:
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or
* ToastAndroid.LONG
*/
import { NativeModules } from 'react-native';
module.exports = NativeModules.ToastAndroid;
然后在其他Jsfiles中尝试使用
导入import ToastAndroid from './ToastAndroid';
【问题讨论】:
标签: react-native