Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vt-rn-pre-study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱传永
vt-rn-pre-study
Commits
8ca425bc
Commit
8ca425bc
authored
Jan 25, 2021
by
zhuchuanyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: rn-navigation
parent
7c0369c7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
0 deletions
+125
-0
StackNavigation.js
src/router/StackNavigation.js
+32
-0
index.js
src/router/index.js
+7
-0
Details.js
src/views/Details.js
+57
-0
Home.js
src/views/Home.js
+29
-0
No files found.
src/router/StackNavigation.js
0 → 100644
View file @
8ca425bc
/*
* @Author: zhuchuanyong
* @Date: 2021-01-25 14:42:30
* @LastEditors: zhuchuanyong
* @LastEditTime: 2021-01-25 17:18:22
* @FilePath: \src\router\StackNavigation.js
*/
import
React
from
'react'
;
import
{
NavigationContainer
}
from
'@react-navigation/native'
;
import
{
createStackNavigator
}
from
'@react-navigation/stack'
;
import
Home
from
'../views/Home'
;
import
Details
from
'../views/Details'
;
const
Stack
=
createStackNavigator
();
function
StackNavigation
()
{
return
(
<
NavigationContainer
>
<
Stack
.
Navigator
initialRouteName
=
"Home"
>
<
Stack
.
Screen
name
=
"Home"
options
=
{{
title
:
'设置Title'
}}
component
=
{
Home
}
/
>
<
Stack
.
Screen
name
=
"Details"
component
=
{
Details
}
/
>
<
/Stack.Navigator
>
<
/NavigationContainer
>
);
}
export
default
StackNavigation
;
src/router/index.js
0 → 100644
View file @
8ca425bc
/*
* @Author: zhuchuanyong
* @Date: 2021-01-25 14:42:04
* @LastEditors: zhuchuanyong
* @LastEditTime: 2021-01-25 14:42:05
* @FilePath: \src\router\index.js
*/
src/views/Details.js
0 → 100644
View file @
8ca425bc
/*
* @Author: zhuchuanyong
* @Date: 2021-01-25 14:45:22
* @LastEditors: zhuchuanyong
* @LastEditTime: 2021-01-25 17:49:52
* @FilePath: \src\views\Details.js
*/
import
{
Button
}
from
'@ant-design/react-native'
;
import
React
from
'react'
;
import
{
Text
}
from
'react-native'
;
const
Details
=
(
props
)
=>
{
let
{
navigation
,
route
}
=
props
;
// route?.params 里接收参数
return
(
<>
<
Text
>
Language
:{
route
?.
params
?.
Language
??
''
}
<
/Text
>
<
Text
>
小米
:{
route
?.
params
?.
target
??
''
}
<
/Text
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
navigate
(
'Details'
)}
>
navigate
to
Details
不生效
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
push
(
'Details'
)}
>
push
to
Details
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
push
(
'Details'
,
{
Language
:
'React native 大法好'
,
target
:
' Are you ok'
,
})
}
>
push
to
Details
带参数
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
push
(
'Home'
)}
>
push
回到
Home
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
navigate
(
'Home'
)}
>
navigate
回到
Home
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
goBack
()}
>
返回上一页
<
/Button
>
<
Button
type
=
"primary"
onPress
=
{()
=>
navigation
.
popToTop
()}
>
popToTop
返回到堆栈中的第一个屏幕
<
/Button
>
<
/
>
);
};
export
default
Details
;
src/views/Home.js
0 → 100644
View file @
8ca425bc
/*
* @Author: zhuchuanyong
* @Date: 2021-01-25 14:44:12
* @LastEditors: zhuchuanyong
* @LastEditTime: 2021-01-25 17:45:19
* @FilePath: \src\views\home.js
*/
import
{
Button
}
from
'@ant-design/react-native'
;
import
React
from
'react'
;
const
Home
=
(
props
)
=>
{
let
{
navigation
}
=
props
;
const
gotoDetail
=
()
=>
{
// 跳转页面 并传递参数
navigation
.
navigate
(
'Details'
,
{
Language
:
'React 大发好'
,
target
:
'干翻华为 Are you ok'
,
});
};
return
(
<>
<
Button
type
=
"primary"
onPress
=
{()
=>
gotoDetail
()}
>
Home
<
/Button
>
<
/
>
);
};
export
default
Home
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment