我想按一下从按钮打开一个新文件,我将如何做到这一点,这是我想要打开KidsVideo的文件示例.js
这是主屏幕的代码,我只是无法让它打开另一个文件的新窗口
<TouchableOpacity onPress={kidsvideo} style={styles.panther}>
<Image source={{uri: 'https://vignette.wikia.nocookie.net/avengers-assemble/images/a/a0/Usa_avengers_herochi_blackpanther_r_e1954416.png/revision/latest?cb=20170417131405'}}
style={{width: 190, height: 300, }} />
首先安装 react-native-router-flux,如果你使用的是 npm:
npm install react-native-router-flux
在您的应用程序中.js 然后根据场景文件导入场景并响应本机路由器通量
import FirtScene from './firstscene'
import SecondScene from './secondscene
import { Actions, Router, Scene } from "react-native-router-flux";
然后在应用程序中设置路由器.js
<Router>
<Scene key="app">
<Scene key="scene1" component={FirstScene} hideNavBar />
<Scene key="scene2" component={SecondScene} hideNavBar/>
</Scene>
</Router>
"scene1"将成为您的主屏幕,因为您将其放在第一位
然后在主屏幕("场景 1"(中
import { Actions, Router, Scene } from "react-native-router-flux";
然后从第一个屏幕转到第二个屏幕:
TouchableOpacity onPress={() =>
Actions.scene2()} style={styles.panther}>
我还不明白你的问题。
如果要在屏幕之间导航,可以使用 https://facebook.github.io/react-native/docs/navigation
如果需要路由或导航,可以使用 https://reactnavigation.org
希望对您有所帮助