fmtRouterTitle.js 344 B

12345678910111213
  1. export const fmtTitle = (title, now) => {
  2. const reg = /\$\{(.+?)\}/
  3. const reg_g = /\$\{(.+?)\}/g
  4. const result = title.match(reg_g)
  5. if (result) {
  6. result.forEach((item) => {
  7. const key = item.match(reg)[1]
  8. const value = now.params[key] || now.query[key]
  9. title = title.replace(item, value)
  10. })
  11. }
  12. return title
  13. }