14 lines
344 B
JavaScript
14 lines
344 B
JavaScript
export const fmtTitle = (title, now) => {
|
|
const reg = /\$\{(.+?)\}/
|
|
const reg_g = /\$\{(.+?)\}/g
|
|
const result = title.match(reg_g)
|
|
if (result) {
|
|
result.forEach((item) => {
|
|
const key = item.match(reg)[1]
|
|
const value = now.params[key] || now.query[key]
|
|
title = title.replace(item, value)
|
|
})
|
|
}
|
|
return title
|
|
}
|