2017-06-17 94 views
0

我在我的react-native android項目中使用react-native-router-flux無法解決模塊`react-native-router-flux'

當我運行我的項目時,它在我的emulator上顯示下面的錯誤。

enter image description here

操作系統:Ubuntu的16.04

index.android

import React, { Component } from 'react'; 
import {AppRegistry,StyleSheet,Text,View,Image} from 'react-native'; 
import {Scene, Router} from 'react-native-router-flux'; 

import Movie from './src/view/Movies'; 


export default class testreact extends Component { 
    render() { 
     return 
     <Router > 
     <Scene key="root"> 
      <Scene key="Movie" component={Movie} title="Movie"/> 
     </Scene> 
    </Router> 
    } 
} 

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

電影

import React, {Component} from 'react'; 
import {AppRegistry, StyleSheet,Text, View,Image} from 'react-native'; 
import styles from './../res/styles/style'; 

var MOCKED_MOVIES_DATA = [ 
    {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}}, 
]; 
class Movies extends Component { 
    render() { 
     var movie = MOCKED_MOVIES_DATA[0]; 
     return (
      <View style={styles.container}> 
       <Text>Title : {movie.title}</Text> 
       <Text>Year : {movie.year}</Text> 
       <Image source={{uri:movie.posters.thumbnail}} style={styles.thumbnail}/> 
      </View> 
     ); 
    } 
} 

export default Movies; 

回答

2

使用此命令:npm i react-native-router-flux --save

0

的問題將在import styles from './../res/styles/style';電影組件替換上面這樣的代碼import styles from '../res/styles/style';

4

我開始面對這個問題,並執行以下步驟解決問題:

  1. 更改版本你的react-native-router-flux到3.40.1
  2. 刪除你的node_modules目錄(rm -rf node_modules
  3. 運行npm install
相關問題