mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-09-19 10:19:56 +08:00
* docs(SwipeCell): change "slot" to "v-slot" * docs(SwipeCell): change `v-slot` to`#` * docs(cell): change `slot` to `#` * docs(checkbox): change `slot` to `v-slot` * docs(field): change `slot` to `v-slot` * docs(checkbox): remove wrong comment * docs(radio): change `slot` to `#` * docs(search): change `slot` to `#` * docs(slider): change `slot` to `#` * docs(switch): change `slot` to `#` * docs(PullRefresh): change `slot` to `#` * docs(collapse): change `slot` to `#` * docs(panel): change `slot` to `#` * docs(swipe): change `slot` to `#` * docs(navbar): change `slot` to `#` * docs(tab): change `slot` to `#` * docs(tabber): change `slot` to `#` * docs(TreeSelect): change `slot` to `#` * docs(card): change `slot` to `#` * docs(submitBar): change `slot` to `#` * docs(sku): change `slot` to `#` unsure * docs(cell): delete waste blank line * docs(panel): fix indentation * docs(PullRefresh): change "count" to "Refresh Count" * docs(radio): delete waste blank line * docs(search): move props above the event * docs(submitBar): delete waste `<span>` * docs(swipCell): delete waste blank line * docs(tabbar): merge `<img>` into one line
82 lines
1.4 KiB
Markdown
82 lines
1.4 KiB
Markdown
# NavBar 导航栏
|
|
|
|
### 引入
|
|
|
|
```js
|
|
import Vue from 'vue';
|
|
import { NavBar } from 'vant';
|
|
|
|
Vue.use(NavBar);
|
|
```
|
|
|
|
## 代码演示
|
|
|
|
### 基础用法
|
|
|
|
```html
|
|
<van-nav-bar
|
|
title="标题"
|
|
left-text="返回"
|
|
right-text="按钮"
|
|
left-arrow
|
|
@click-left="onClickLeft"
|
|
@click-right="onClickRight"
|
|
/>
|
|
```
|
|
|
|
```js
|
|
import { Toast } from 'vant';
|
|
|
|
export default {
|
|
methods: {
|
|
onClickLeft() {
|
|
Toast('返回');
|
|
},
|
|
onClickRight() {
|
|
Toast('按钮');
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### 高级用法
|
|
|
|
通过插槽定制内容
|
|
|
|
```html
|
|
<van-nav-bar title="标题" left-text="返回" left-arrow>
|
|
<template #right>
|
|
<van-icon name="search"/>
|
|
</template>
|
|
</van-nav-bar>
|
|
```
|
|
|
|
## API
|
|
|
|
### Props
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|------|------|------|------|
|
|
| title | 标题 | *string* | `''` |
|
|
| left-text | 左侧文案 | *string* | `''` |
|
|
| right-text | 右侧文案 | *string* | `''` |
|
|
| left-arrow | 是否显示左侧箭头 | *boolean* | `false` |
|
|
| fixed | 是否固定在顶部 | *boolean* | `false` |
|
|
| border | 是否显示下边框 | *boolean* | `true` |
|
|
| z-index | 元素 z-index | *number \| string* | `1` |
|
|
|
|
### Slots
|
|
|
|
| 名称 | 说明 |
|
|
|------|------|
|
|
| title | 自定义标题 |
|
|
| left | 自定义左侧区域内容 |
|
|
| right | 自定义右侧区域内容 |
|
|
|
|
### Events
|
|
|
|
| 事件名 | 说明 | 回调参数 |
|
|
|------|------|------|
|
|
| click-left | 点击左侧按钮时触发 | - |
|
|
| click-right | 点击右侧按钮时触发 | - |
|