diff --git a/components.js b/components.js
index dd814eeee..7eb55865c 100644
--- a/components.js
+++ b/components.js
@@ -76,4 +76,5 @@ module.exports = [
'coupon',
'coupon-list',
'coupon-cell',
+ 'submit-bar',
];
diff --git a/src/submit-bar/index.js b/src/submit-bar/index.js
new file mode 100644
index 000000000..daa158683
--- /dev/null
+++ b/src/submit-bar/index.js
@@ -0,0 +1,104 @@
+import { createNamespace } from '../utils';
+import Icon from '../icon';
+import Button from '../button';
+
+const [createComponent, bem, t] = createNamespace('submit-bar');
+
+export default createComponent({
+ props: {
+ tip: String,
+ label: String,
+ price: Number,
+ tipIcon: String,
+ loading: Boolean,
+ disabled: Boolean,
+ textAlign: String,
+ buttonText: String,
+ buttonColor: String,
+ suffixLabel: String,
+ safeAreaInsetBottom: {
+ type: Boolean,
+ default: true,
+ },
+ decimalLength: {
+ type: [Number, String],
+ default: 2,
+ },
+ currency: {
+ type: String,
+ default: '¥',
+ },
+ buttonType: {
+ type: String,
+ default: 'danger',
+ },
+ },
+
+ emits: ['submit'],
+
+ setup(props, { emit, slots }) {
+ return () => {
+ const { tip, price, tipIcon } = props;
+
+ function Text() {
+ if (typeof price === 'number') {
+ const priceArr = (price / 100)
+ .toFixed(props.decimalLength)
+ .split('.');
+ const decimalStr = props.decimalLength ? `.${priceArr[1]}` : '';
+ return (
+
+ {props.label || t('label')}
+
+ {props.currency}
+ {priceArr[0]}
+ {decimalStr}
+
+ {props.suffixLabel && (
+ {props.suffixLabel}
+ )}
+
+ );
+ }
+ }
+
+ function Tip() {
+ if (slots.tip || tip) {
+ return (
+
+ {tipIcon && }
+ {tip && {tip}}
+ {slots.tip && slots.tip()}
+
+ );
+ }
+ }
+
+ return (
+
+ {slots.top && slots.top()}
+ {Tip()}
+
+ {slots.default && slots.default()}
+ {Text()}
+
+
+ );
+ };
+ },
+});
diff --git a/src/submit-bar/index.tsx b/src/submit-bar/index.tsx
deleted file mode 100644
index 9e8092b4f..000000000
--- a/src/submit-bar/index.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-// Utils
-import { createNamespace } from '../utils';
-import { emit, inherit } from '../utils/functional';
-
-// Components
-import Icon from '../icon';
-import Button, { ButtonType } from '../button';
-
-// Types
-import { CreateElement, RenderContext } from 'vue/types';
-import { ScopedSlot, DefaultSlots } from '../utils/types';
-
-export type SubmitBarProps = {
- tip?: string;
- tipIcon?: string;
- label?: string;
- price?: number;
- loading?: boolean;
- currency: string;
- disabled?: boolean;
- buttonType: ButtonType;
- buttonText?: string;
- buttonColor?: string;
- suffixLabel?: string;
- decimalLength: number;
- safeAreaInsetBottom?: boolean;
- textAlign?: 'right' | 'left';
-};
-
-export type SubmitBarSlots = DefaultSlots & {
- top?: ScopedSlot;
- tip?: ScopedSlot;
-};
-
-const [createComponent, bem, t] = createNamespace('submit-bar');
-
-function SubmitBar(
- h: CreateElement,
- props: SubmitBarProps,
- slots: SubmitBarSlots,
- ctx: RenderContext
-) {
- const { tip, price, tipIcon } = props;
-
- function Text() {
- if (typeof price === 'number') {
- const priceArr = (price / 100).toFixed(props.decimalLength).split('.');
- const decimalStr = props.decimalLength ? `.${priceArr[1]}` : '';
- return (
-
- {props.label || t('label')}
-
- {props.currency}
- {priceArr[0]}
- {decimalStr}
-
- {props.suffixLabel && (
- {props.suffixLabel}
- )}
-
- );
- }
- }
-
- function Tip() {
- if (slots.tip || tip) {
- return (
-
- {tipIcon && }
- {tip && {tip}}
- {slots.tip && slots.tip()}
-
- );
- }
- }
-
- return (
-
- {slots.top && slots.top()}
- {Tip()}
-
- {slots.default && slots.default()}
- {Text()}
-
-
- );
-}
-
-SubmitBar.props = {
- tip: String,
- label: String,
- price: Number,
- tipIcon: String,
- loading: Boolean,
- disabled: Boolean,
- textAlign: String,
- buttonText: String,
- buttonColor: String,
- suffixLabel: String,
- safeAreaInsetBottom: {
- type: Boolean,
- default: true,
- },
- decimalLength: {
- type: [Number, String],
- default: 2,
- },
- currency: {
- type: String,
- default: '¥',
- },
- buttonType: {
- type: String,
- default: 'danger',
- },
-};
-
-export default createComponent(SubmitBar);
diff --git a/vant.config.js b/vant.config.js
index bb58b6e79..735c200f6 100644
--- a/vant.config.js
+++ b/vant.config.js
@@ -351,10 +351,10 @@ module.exports = {
// path: 'goods-action',
// title: 'GoodsAction 商品导航',
// },
- // {
- // path: 'submit-bar',
- // title: 'SubmitBar 提交订单栏',
- // },
+ {
+ path: 'submit-bar',
+ title: 'SubmitBar 提交订单栏',
+ },
// {
// path: 'sku',
// title: 'Sku 商品规格',
@@ -685,10 +685,10 @@ module.exports = {
// path: 'goods-action',
// title: 'GoodsAction',
// },
- // {
- // path: 'submit-bar',
- // title: 'SubmitBar',
- // },
+ {
+ path: 'submit-bar',
+ title: 'SubmitBar',
+ },
// {
// path: 'sku',
// title: 'Sku',