mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(CouponList): fix scroll issue (#9480)
* fix(CouponList): fix scroll issue * perf: using vh instead of window height
This commit is contained in:
parent
ba5a70d5bc
commit
ac08bd9dab
@ -12,7 +12,6 @@ import {
|
|||||||
import { truthProp, createNamespace } from '../utils';
|
import { truthProp, createNamespace } from '../utils';
|
||||||
|
|
||||||
// Composables
|
// Composables
|
||||||
import { useWindowSize } from '@vant/use';
|
|
||||||
import { useRefs } from '../composables/use-refs';
|
import { useRefs } from '../composables/use-refs';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
@ -83,8 +82,6 @@ export default defineComponent({
|
|||||||
code: props.code,
|
code: props.code,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { height: windowHeight } = useWindowSize();
|
|
||||||
|
|
||||||
const buttonDisabled = computed(
|
const buttonDisabled = computed(
|
||||||
() =>
|
() =>
|
||||||
!props.exchangeButtonLoading &&
|
!props.exchangeButtonLoading &&
|
||||||
@ -93,10 +90,6 @@ export default defineComponent({
|
|||||||
state.code.length < props.exchangeMinLength)
|
state.code.length < props.exchangeMinLength)
|
||||||
);
|
);
|
||||||
|
|
||||||
const listStyle = computed(() => ({
|
|
||||||
height: windowHeight.value - (props.showExchangeBar ? 140 : 94) + 'px',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const onExchange = () => {
|
const onExchange = () => {
|
||||||
emit('exchange', state.code);
|
emit('exchange', state.code);
|
||||||
|
|
||||||
@ -155,8 +148,10 @@ export default defineComponent({
|
|||||||
return (
|
return (
|
||||||
<Tab title={title}>
|
<Tab title={title}>
|
||||||
<div
|
<div
|
||||||
class={bem('list', { 'with-bottom': props.showCloseButton })}
|
class={bem('list', {
|
||||||
style={listStyle.value}
|
'with-bar': props.showExchangeBar,
|
||||||
|
'with-bottom': props.showCloseButton,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{coupons.map((coupon, index) => (
|
{coupons.map((coupon, index) => (
|
||||||
<Coupon
|
<Coupon
|
||||||
@ -183,8 +178,10 @@ export default defineComponent({
|
|||||||
return (
|
return (
|
||||||
<Tab title={title}>
|
<Tab title={title}>
|
||||||
<div
|
<div
|
||||||
class={bem('list', { 'with-bottom': props.showCloseButton })}
|
class={bem('list', {
|
||||||
style={listStyle.value}
|
'with-bar': props.showExchangeBar,
|
||||||
|
'with-bottom': props.showCloseButton,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{disabledCoupons.map((coupon) => (
|
{disabledCoupons.map((coupon) => (
|
||||||
<Coupon
|
<Coupon
|
||||||
|
@ -110,7 +110,6 @@ const onExchange = () => {
|
|||||||
:coupons="coupons"
|
:coupons="coupons"
|
||||||
:chosen-coupon="chosenCoupon"
|
:chosen-coupon="chosenCoupon"
|
||||||
:disabled-coupons="disabledCoupons"
|
:disabled-coupons="disabledCoupons"
|
||||||
:show-count="false"
|
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
@exchange="onExchange"
|
@exchange="onExchange"
|
||||||
/>
|
/>
|
||||||
|
@ -56,10 +56,15 @@
|
|||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
height: calc(100vh - 108px);
|
||||||
padding: var(--van-padding-md) 0 var(--van-padding-lg);
|
padding: var(--van-padding-md) 0 var(--van-padding-lg);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
|
&--with-bar {
|
||||||
|
height: calc(100vh - 152px);
|
||||||
|
}
|
||||||
|
|
||||||
&--with-bottom {
|
&--with-bottom {
|
||||||
padding-bottom: 50px;
|
padding-bottom: 50px;
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,7 @@ exports[`should be the sames as the last snapshot when render coupon list 1`] =
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style
|
style
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon">
|
<div class="van-coupon">
|
||||||
<div class="van-coupon__content">
|
<div class="van-coupon__content">
|
||||||
<div class="van-coupon__head">
|
<div class="van-coupon__head">
|
||||||
@ -334,9 +332,7 @@ exports[`should have two "van-coupon-list__empty" classes when render coupon lis
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon-list__empty">
|
<div class="van-coupon-list__empty">
|
||||||
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
||||||
<p>
|
<p>
|
||||||
@ -349,9 +345,7 @@ exports[`should have two "van-coupon-list__empty" classes when render coupon lis
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style
|
style
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon-list__empty">
|
<div class="van-coupon-list__empty">
|
||||||
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
||||||
<p>
|
<p>
|
||||||
@ -432,9 +426,7 @@ exports[`should render list-footer slot correctly 1`] = `
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon-list__empty">
|
<div class="van-coupon-list__empty">
|
||||||
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
||||||
<p>
|
<p>
|
||||||
@ -448,9 +440,7 @@ exports[`should render list-footer slot correctly 1`] = `
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style
|
style
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon-list__empty">
|
<div class="van-coupon-list__empty">
|
||||||
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
<img src="https://img.yzcdn.cn/vant/coupon-empty.png">
|
||||||
<p>
|
<p>
|
||||||
@ -532,9 +522,7 @@ exports[`should use custom src when using empty-image prop 1`] = `
|
|||||||
class="van-tab__pane"
|
class="van-tab__pane"
|
||||||
style
|
style
|
||||||
>
|
>
|
||||||
<div class="van-coupon-list__list van-coupon-list__list--with-bottom"
|
<div class="van-coupon-list__list van-coupon-list__list--with-bar van-coupon-list__list--with-bottom">
|
||||||
style="height: 628px;"
|
|
||||||
>
|
|
||||||
<div class="van-coupon-list__empty">
|
<div class="van-coupon-list__empty">
|
||||||
<img src="https://img.yzcdn.com/xxx.png">
|
<img src="https://img.yzcdn.com/xxx.png">
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user