# SubmitBar 提交订单栏

### 引入

在`index.config.js中引入组件

```json
"usingComponents": {
  "van-submit-bar": "@vant/weapp/submit-bar/index"
}
```

## 代码演示

### 基础用法

```html
<van-submit-bar
   price={6666}
   buttonText="提交订单"
   onSubmit={() => this.onClickButton()}
   customClass="van-submit-bar"
   safeAreaInsetBottom={false}
/>
```

```javascript

   onClickButton() {
     console.log('点击按钮');
   }

```

### 禁用状态

禁用状态下不会触发`submit`事件

```html
<van-submit-bar
  disabled
  price={6666}
  tip="您的收货地址不支持同城送, 我们已为您推荐快递"
  tipIcon="//img.yzcdn.cn/public_files/2017/8/10/6af5b7168eed548100d9041f07b7c616.png"
  onSubmit={() => this.onClickButton()}
  customClass="van-submit-bar"
  safeAreaInsetBottom={false}
/>
```

### 加载状态

加载状态下不会触发`submit`事件

```html
<van-submit-bar
  loading
  price={6666}
  buttonText="提交订单"
  onSubmit={() => this.onClickButton()}
  customClass="van-submit-bar"
  safeAreaInsetBottom={false}
/>
```

### 高级用法

通过插槽插入自定义内容

```html
<van-submit-bar
   price={6666}
   buttonText="提交订单"
   onSubmit={() => this.onClickButton()}
   customClass="van-submit-bar"
   tip={true}
   safeAreaInsetBottom={false}
>
  <van-tag type="primary" customClass="submit-tag">标签</van-tag>
</van-submit-bar>
```

## API
### 注:属性应用在组件上需要统一使用驼峰式命名，如custom-class应变为
```html
<van-button type="primary" customClass='myClass' size="large">大号按钮</van-button>
```
### 注:事件应用在组件上需要统一使用驼峰式命名，如bind:click/bind:search/bind:before-enter应变为
```html
<van-button type="primary" onClick={()=>this.onClick()}>大号按钮</van-button>
<van-search type="primary" onSearch={()=>this.onSearch()}>大号按钮</van-search>
<van-transition type="primary" onBeforeEnter={()=>this.onBeforeEnter()}>大号按钮</van-transition>
```
### Props

| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| price | 价格（单位分） | _number_ | - | - |
| label | 价格文案 | _string_ | `合计：` | - |
| suffix-label | 价格右侧文案 | _string_ | - | - |
| button-text | 按钮文字 | _string_ | - | - |
| button-type | 按钮类型 | _string_ | `danger` | - |
| tip | 提示文案 | _string \| boolean_ | - | - |
| tip-icon | 图标名称或图片链接，可选值见 [Icon 组件](#/icon) | _string_ | - | - |
| disabled | 是否禁用按钮 | _boolean_ | `false` | - |
| loading | 是否显示加载中的按钮 | _boolean_ | `false` | - |
| currency | 货币符号 | _string_ | `¥` | - |
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | _boolean_ | `true` | - |
| decimal-length | 价格小数点后位数 | _number_ | `2` | - |

### Events

| 事件名 | 说明             | 参数 |
| ------ | ---------------- | ---- |
| submit | 按钮点击事件回调 | -    |

### Slot

| 名称 | 说明                       |
| ---- | -------------------------- |
| -    | 自定义订单栏左侧内容       |
| top  | 自定义订单栏上方内容       |
| tip  | 提示文案中的额外操作和说明 |

### 外部样式类

| 类名         | 说明         |
| ------------ | ------------ |
| custom-class | 根节点样式类 |
| price-class  | 价格样式类   |
| button-class | 按钮样式类   |
| bar-class    | 订单栏样式类 |
