【问题标题】:No view Manager defined for class RCTMap没有为类 RCTMap 定义视图管理器
【发布时间】:2015-12-14 00:33:49
【问题描述】:

我正在尝试将MapView for Android 与 react-native 一起使用。这是我的(非常基本的)代码:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var {
  AppRegistry,
  Image,
  ListView,
  StyleSheet,
  Text,
  TextInput,
  View,
  ToastAndroid,
  MapView,
  ToolbarAndroid
} = React;

var SwitchAndroid = require('SwitchAndroid');

var toolbarActions = [
  {title: 'Create', icon: require('image!ic_create_black_48dp'), show: 'always'},
  {title: 'Filter'},
  {title: 'Settings', icon: require('image!ic_settings_black_48dp'), show: 'always'},
];
var velib = React.createClass({
    getInitialState: function() {
    return {
      actionText: 'Example app with toolbar component',
      toolbarSwitch: false,
      colorProps: {
        titleColor: '#3b5998',
        subtitleColor: '#6a7180',
      },
    };
  },
    render: function() {
        return (
            <View>
                 <ToolbarAndroid
                    actions={toolbarActions}
                    navIcon={require('image!ic_menu_black_24dp')}
                    onActionSelected={this._onActionSelected}
                    onIconClicked={() => this.setState({actionText: 'Icon clicked'})}
                    style={styles.toolbar}
                    subtitle={this.state.actionText}
                    title="Toolbar" 
                />
                <MapView
                    showsUserLocation="true"
                />
            </View>
        )
    },
    onActionSelected: function(position) {
      if (position === 0) { // index of 'Settings'
        showSettings();
      }
}
});

var styles = StyleSheet.create({
  toolbar: {
    backgroundColor: '#e9eaed',
    height: 56,
  },
   map: {
    height: 150,
    margin: 10,
    borderWidth: 1,
    borderColor: '#000000',
  },
});


AppRegistry.registerComponent('velib', () => velib);

但我总是得到这个错误:

这是我的 logcat 错误:

W/ReactNativeJS(18572): 'Warning: Native component for "RCTModalHostView" does not exist'
W/ReactNativeJS(18572): 'Warning: Native component for "RCTTextView" does not exist'
W/ReactNativeJS(18572): 'Warning: Native component for "RCTTextField" does not exist'
D/ReactNativeJS(18572): 'Running application "velib" with appParams: {"initialProps":{},"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF'

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    Android 地图在最初的 android 版本中尚未开源。有一个视图和模块列表将随着时间的推移而开源here

    【讨论】:

    • 哦……对。那么,正确的答案是“等到它开源”?谢谢。
    • 我正在运行一个空白项目并且有警告:“RCTMap”的本机组件不存在警告:“RCTModalHostView”的本机组件不存在警告:“RCTWebView”的本机组件不存在什么这是?
    猜你喜欢
    • 2015-06-12
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 2021-03-06
    • 2019-07-02
    • 2023-03-05
    相关资源
    最近更新 更多