Merge branch '2.x' into dev

This commit is contained in:
chenjiahan
2020-10-31 18:19:32 +08:00
29 changed files with 324 additions and 69 deletions
+7 -6
View File
@@ -61,6 +61,7 @@ Use slot to add custom contents.
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| price | Price | _number_ | - |
| decimal-length | Price dicemal length | _number \| string_ | `2` |
| label | Price left label | _string_ | `Total` |
| suffix-label | Price right label | _string_ | - |
| text-align `v2.3.0` | Price label text align can be set to `left` | _string_ | `right` |
@@ -70,7 +71,6 @@ Use slot to add custom contents.
| tip | Tip | _string_ | - |
| tip-icon | Icon | _string_ | - |
| currency | Currency symbol | _string_ | `¥` |
| decimal-length | number of digits to appear after the decimal point | _number \| string_ | `2` |
| disabled | Whether to disable button | _boolean_ | `false` |
| loading | Whether to show loading icon | _boolean_ | `false` |
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
@@ -83,8 +83,9 @@ Use slot to add custom contents.
### Slots
| Name | Description |
| ------- | ------------------- |
| default | Custom left content |
| top | Custom top content |
| tip | Custom tips |
| Name | Description |
| ----------------- | ------------------- |
| default | Custom left content |
| button `v2.10.12` | Custom button |
| top | Custom top content |
| tip | Custom tips |
+10 -9
View File
@@ -66,18 +66,18 @@ app.use(SubmitBar);
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| price | 价格(单位分) | _number_ | - |
| decimal-length | 价格小数点位数 | _number \| string_ | `2` |
| label | 价格左侧文案 | _string_ | `合计:` |
| suffix-label | 价格右侧文案 | _string_ | - |
| text-align `v2.3.0` | 价格文案对齐方向,可选值为 `left` | _string_ | `right` |
| button-text | 按钮文字 | _string_ | - |
| button-type | 按钮类型 | _string_ | `danger` |
| button-color `v2.9.1` | 自定义按钮颜色 | _string_ | - |
| tip | 提示文案 | _string_ | - |
| tip-icon | 左侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
| tip | 在订单栏上方的提示文案 | _string_ | - |
| tip-icon | 提示文案左侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
| currency | 货币符号 | _string_ | `¥` |
| decimal-length | 价格小数点后位数 | _number \| string_ | `2` |
| disabled | 是否禁用按钮 | _boolean_ | `false` |
| loading | 是否显示加载中的按钮 | _boolean_ | `false` |
| loading | 是否显示将按钮显示为加载中状态 | _boolean_ | `false` |
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
### Events
@@ -88,8 +88,9 @@ app.use(SubmitBar);
### Slots
| 名称 | 说明 |
| ------- | -------------------------- |
| default | 自定义订单栏左侧内容 |
| top | 自定义订单栏上方内容 |
| tip | 提示文案中的额外操作和说明 |
| 名称 | 说明 |
| ----------------- | -------------------- |
| default | 自定义订单栏左侧内容 |
| button `v2.10.12` | 自定义按钮 |
| top | 自定义订单栏上方内容 |
| tip | 提示文案中的额外内容 |
+18 -12
View File
@@ -84,18 +84,24 @@ export default createComponent({
emit('submit');
};
const renderButton = () => (
<Button
round
type={props.buttonType}
text={props.buttonText}
class={bem('button', props.buttonType)}
color={props.buttonColor}
loading={props.loading}
disabled={props.disabled}
onClick={onClickButton}
/>
);
const renderButton = () => {
if (slots.button) {
return slots.button();
}
return (
<Button
round
type={props.buttonType}
text={props.buttonText}
class={bem('button', props.buttonType)}
color={props.buttonColor}
loading={props.loading}
disabled={props.disabled}
onClick={onClickButton}
/>
);
};
return () => (
<div class={bem({ unfit: !props.safeAreaInsetBottom })}>
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`button slot 1`] = `
<div class="van-submit-bar">
<div class="van-submit-bar__bar">Custom button</div>
</div>
`;
exports[`button-color prop 1`] = `
<div class="van-submit-bar">
<div class="van-submit-bar__bar"><button class="van-button van-button--danger van-button--normal van-button--round van-submit-bar__button van-submit-bar__button--danger" style="color: rgb(255, 255, 255); background: red; border-color: red;">
@@ -57,7 +63,7 @@ exports[`text-align prop 1`] = `
`;
exports[`top slot 1`] = `
<div class="van-submit-bar">top<div class="van-submit-bar__bar"><button class="van-button van-button--danger van-button--normal van-button--round van-submit-bar__button van-submit-bar__button--danger">
<div class="van-submit-bar">Custom Top<div class="van-submit-bar__bar"><button class="van-button van-button--danger van-button--normal van-button--round van-submit-bar__button van-submit-bar__button--danger">
<div class="van-button__content"></div>
</button></div>
</div>
+12 -1
View File
@@ -52,7 +52,7 @@ test('without price', () => {
test('top slot', () => {
const wrapper = mount(SubmitBar, {
scopedSlots: {
top: () => 'top',
top: () => 'Custom Top',
},
});
@@ -119,3 +119,14 @@ test('button-color prop', () => {
});
expect(wrapper).toMatchSnapshot();
});
test('button slot', () => {
const wrapper = mount(SubmitBar, {
buttonText: 'text',
scopedSlots: {
button: () => 'Custom button',
},
});
expect(wrapper).toMatchSnapshot();
});