common.js 213 B

12345678910
  1. export function trim (str) {
  2. if (!str) return str
  3. return str.replace(/^\s+|\s+$/g, '')
  4. }
  5. export function toCommaList (arr, key = 'name') {
  6. if (!arr) return
  7. return arr.map(item => item[key]).join(', ')
  8. }