You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
862 B

3 years ago
  1. <template>
  2. <view class="mix-price-view" :style="{fontSize: size - 8 + 'rpx'}">
  3. <text></text>
  4. <text class="price" :style="{fontSize: size + 'rpx'}">{{ priceArr[0] }}</text>
  5. <text>.{{ priceArr[1] }}</text>
  6. </view>
  7. </template>
  8. <script>
  9. /**
  10. * 价格显示组件
  11. */
  12. export default {
  13. data() {
  14. return {
  15. priceArr: []
  16. };
  17. },
  18. props: {
  19. price: {
  20. type: Number,
  21. default: 0
  22. },
  23. size: {
  24. type: Number,
  25. default: 36
  26. }
  27. },
  28. watch: {
  29. price(){
  30. this.render();
  31. }
  32. },
  33. created() {
  34. this.render();
  35. },
  36. methods: {
  37. render(){
  38. const price = parseFloat(this.price).toFixed(2);
  39. this.priceArr = (''+price).split('.');
  40. }
  41. }
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. .mix-price-view{
  46. color: $base-color;
  47. }
  48. .price{
  49. font-weight: 700;
  50. }
  51. </style>