format.js 418 B

123456789101112131415161718192021
  1. export default {
  2. install (vue) {
  3. const format = {
  4. price (price, currency = 'rmb') {
  5. const currencyList = {
  6. rmb: {
  7. icon: '¥',
  8. unit: '元',
  9. },
  10. }
  11. return currencyList[currency].icon +
  12. Number(price).toFixed(2) +
  13. currencyList[currency].unit
  14. },
  15. }
  16. vue.prototype.$format = format
  17. vue.format = format
  18. },
  19. }