# Navigation | 导航
## Instructions
This example demonstrates how to handle navigation and routing with uView Pro in UniAppX.
### Key Concepts
- Page navigation with uView Pro components
- URL parameters passing
- Navigation lifecycle
- Custom navigation bar with uView Pro
- Tab bar navigation
### 使用 UniAppX 导航 API
#### 页面跳转
```typescript
// 保留当前页面,跳转到应用内的某个页面
uni.navigateTo({
url: '/pages/detail/detail?id=1'
})
// 关闭当前页面,跳转到应用内的某个页面
uni.redirectTo({
url: '/pages/login/login'
})
// 跳转到 tabBar 页面
uni.switchTab({
url: '/pages/index/index'
})
// 返回上一页面
uni.navigateBack({
delta: 1
})
```
#### 使用 uView Pro 按钮进行跳转
```vue
跳转到详情页
```
### 使用 uView Pro 导航栏
#### 自定义导航栏
```json
{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom"
}
}
]
}
```
页面中使用 uView Pro 导航栏:
```vue
```
### 使用 uView Pro 返回顶部
```vue
```
### TabBar 导航
#### 使用原生 TabBar
```json
{
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#409EFF",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页"
},
{
"pagePath": "pages/user/user",
"text": "我的"
}
]
}
}
```
#### 使用 uView Pro TabBar 组件
```vue
```
### 页面传参
#### 传递参数
```typescript
// 跳转并传递参数
uni.navigateTo({
url: '/pages/detail/detail?id=1&name=test'
})
```
#### 接收参数
```vue
ID: {{ id }}
Name: {{ name }}
```
### 使用 uView Pro 搜索框导航
```vue
```
### 导航栏返回按钮自定义
```vue
```
## 注意事项
1. **路径格式**:路径必须以 `/` 开头
2. **TabBar 跳转**:使用 `uni.switchTab` 跳转到 tabBar 页面
3. **参数传递**:URL 参数需要编码
4. **页面栈**:注意页面栈限制(最多 10 层)
5. **返回按钮**:自定义导航栏需要自己处理返回逻辑
6. **TypeScript**:使用 TypeScript 类型定义,确保类型安全