node.js窗口上的错误:
错误:捆绑失败:错误:无法解析react-native-gesture-handler
中的模块node_modules\@react-navigation\native\src\Scrollables.js
:在项目中找不到react-native-gesture-handler。
我认为错误与npm或毛线库有关。
App.js代码:
import React, {Component} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Button
} from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation';
class FirstPage extends Component{
render(){
return(
<View>
<Text>This is the first page.</Text>
<Button onPress={()=>this.props.navigation.navigate('test')} title="Go to the second page"/>
</View>
)
}
}
class SecondPage extends Component{
render(){
return(
<View>
<Text>This is the second page.</Text>
<Button onPress={()=>this.props.navigation.navigate('home')} title="Go to the first page"/>
</View>
)
}
}
export default createStackNavigator({
home:FirstPage,
test:SecondPage
});
答案 0 :(得分:1)
您只需要安装react-native-gesture-handler
,因为react-navaigation
使用了它。因此,有关更多说明,您可以阅读文档https://reactnavigation.org/
答案 1 :(得分:1)
您需要安装以下软件包以及raeact导航才能使其正常工作,
您可以添加
yarn add react-navigation react-native-gesture-handler react-native-reanimated react-native-screens
或
npm i react-navigation react-native-gesture-handler react-native-reanimated react-native-screens
希望有帮助。毫无疑问