我正在尝试使用上面引用的库之一,react-native-splash-screen和 react-navigation .我明白了
.
代码如下:
index.android.js
import { AppRegistry } from 'react-native';
import App from './app/index';
AppRegistry.registerComponent('RecallNotes', () => App);
索引.js
import React, { Component } from 'react';
import Root from 'config/router';
import {
View,
} from 'react-native';
import SplashScreen from 'react-native-smart-splash-screen';
export default class App extends Component {
componentDidMount () {
//SplashScreen.close(SplashScreen.animationType.scale, 850, 500)
SplashScreen.close({
animationType: SplashScreen.animationType.scale,
duration: 850,
delay: 500,
})
}
render() {
return <Root />;
}
}
路由器.js
import React from 'react';
import { StackNavigator } from 'react-navigation';
import DeckView from 'screens/deckview';
export const Root = StackNavigator({
Home: {
screen: DeckView
},
},{
mode: 'modal',
headerMode: 'none',
});
甲板 View .js
import React, { Component } from 'react';
import {
View,
Text
} from 'react-native';
/*
* DeckView class
* This is the component of the deck image
*/
export default class DeckView extends Component{
render(){
return(
<View>
<Text>Welcome to React Native!</Text>
</View>
);
}
}
我的问题是:我是否必须在我的应用程序的整个导航中使用 StackNavigator,或者我可以在修复此代码后保留上面的代码吗?谢谢。
最佳答案
在 index.js 中,更改:
从 'config/router' 导入 Root;
到:
从 'config/router' 导入 { Root };
因为您没有从 router.js 导出默认值
关于javascript - React-native 启动画面和 react-navigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44316862/