diff --git a/packages/vant-cli/site/common/index.js b/packages/vant-cli/site/common/index.js index 38d345ea8..6cf96dab9 100644 --- a/packages/vant-cli/site/common/index.js +++ b/packages/vant-cli/site/common/index.js @@ -4,9 +4,7 @@ function iframeReady(iframe, callback) { if (iframe.contentWindow.replacePath) { callback(); } else { - setTimeout(() => { - interval(); - }, 50); + setTimeout(interval, 50); } }; diff --git a/src/notify/index.js b/src/notify/index.js index 2c5a80065..5e72f66df 100644 --- a/src/notify/index.js +++ b/src/notify/index.js @@ -42,7 +42,7 @@ function Notify(options) { instance.open(options); clearTimeout(timer); - if (options.duration && options.duration > 0) { + if (options.duration > 0) { timer = setTimeout(Notify.clear, options.duration); } diff --git a/src/submit-bar/index.js b/src/submit-bar/index.js index daa158683..64b6b7baa 100644 --- a/src/submit-bar/index.js +++ b/src/submit-bar/index.js @@ -37,68 +37,76 @@ export default createComponent({ emits: ['submit'], setup(props, { emit, slots }) { - return () => { - const { tip, price, tipIcon } = props; + const renderText = () => { + const { + price, + label, + currency, + textAlign, + suffixLabel, + decimalLength, + } = 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} - )} -
- ); - } - } + if (typeof price === 'number') { + const pricePair = (price / 100).toFixed(decimalLength).split('.'); + const decimal = decimalLength ? `.${pricePair[1]}` : ''; - 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()} -
- ); + ); + } }; + + const renderTip = () => { + const { tip, tipIcon } = props; + if (slots.tip || tip) { + return ( +
+ {tipIcon && } + {tip && {tip}} + {slots.tip?.()} +
+ ); + } + }; + + const onClickButton = () => { + emit('submit'); + }; + + const renderButton = () => ( +