本文主要是介绍React Native之编译提示Only one default export allowed per module.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1 问题
部分代码如下
class HomeScreen extends React.Component {render() {return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}><Text>Home Screen</Text></View>);}
}export default createStackNavigator({Home: {screen: HomeScreen},
});export default class App extends React.Component {render() {return <RootStack/>;}
}
2 解决办法
export default 声明只能有一个,改成如下即可
import React from 'react';
import { View, Text } from 'react-native';
import { createStackNavigator } from 'react-navigation';class HomeScreen extends React.Component {render() {return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}><Text>Home Screen</Text></View>);}
}const RootStack = createStackNavigator({Home : {screen : HomeScreen},
});export default class App extends React.Component {render() {return <RootStack/>;}
}
这篇关于React Native之编译提示Only one default export allowed per module.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!