mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +08:00
fix(Card): render correctly when the price is an integer (#12917)
This commit is contained in:
parent
f937005f2b
commit
4d1e1b5871
@ -108,8 +108,12 @@ export default defineComponent({
|
||||
return (
|
||||
<div>
|
||||
<span class={bem('price-currency')}>{props.currency}</span>
|
||||
<span class={bem('price-integer')}>{priceArr[0]}</span>.
|
||||
<span class={bem('price-decimal')}>{priceArr[1]}</span>
|
||||
<span class={bem('price-integer')}>{priceArr[0]}</span>
|
||||
{priceArr.length > 1 && (
|
||||
<>
|
||||
.<span class={bem('price-decimal')}>{priceArr[1]}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -44,6 +44,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<span class="van-card__price-integer">
|
||||
2
|
||||
</span>
|
||||
<!--[-->
|
||||
.
|
||||
<span class="van-card__price-decimal">
|
||||
00
|
||||
@ -109,6 +110,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<span class="van-card__price-integer">
|
||||
2
|
||||
</span>
|
||||
<!--[-->
|
||||
.
|
||||
<span class="van-card__price-decimal">
|
||||
00
|
||||
@ -183,6 +185,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<span class="van-card__price-integer">
|
||||
2
|
||||
</span>
|
||||
<!--[-->
|
||||
.
|
||||
<span class="van-card__price-decimal">
|
||||
00
|
||||
|
@ -86,3 +86,13 @@ test('should render price and price-top slot correctly', () => {
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render correctly when the price is an integer', () => {
|
||||
const wrapper = mount(Card, {
|
||||
props: {
|
||||
price: 12,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.find('.van-card__price').text()).toEqual('¥12');
|
||||
});
|
||||
|
@ -115,6 +115,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<span class="van-card__price-integer">
|
||||
2
|
||||
</span>
|
||||
<!--[-->
|
||||
.
|
||||
<span class="van-card__price-decimal">
|
||||
00
|
||||
|
Loading…
x
Reference in New Issue
Block a user