i18n相关的问题
dybxin opened this issue · 0 comments
dybxin commented
我有注意到你在permission.ts中定义的有如下代码:
// const getPageTitle = (key: string) => {
// const i18n = useI18n()
// const title = settings.title
// const hasKey = i18n.te(`route.${key}`)
// if (hasKey) {
// const pageName = i18n.t(`route.${key}`)
// return `${pageName} - ${title}`
// }
// return `${title}`
// }
我其实在vue-element-admin中的utils/get-page-title.js的基础上修改
import defaultSettings from '@/settings'
import i18n from'@/locales'
const title = defaultSettings.title || 'Vue3 Admin Template'
export default function getPageTitle(key) {
const hasKey = i18n.te(`route.${key}`)
if (hasKey) {
const pageName = i18n.t(`route.${key}`)
return `${pageName} - ${title}`
}
return `${title}`
}
遇到如下问题:
vue-router.esm-bundler.js?6c02:3248 TypeError: _locales__WEBPACK_IMPORTED_MODULE_2__.default.te is not a function
at getPageTitle (get-page-title.js?036d:7)
at _callee$ (permission.js?223d:19)
at tryCatch (runtime.js?96cf:63)
at Generator.invoke [as _invoke] (runtime.js?96cf:293)
at Generator.eval [as next] (runtime.js?96cf:118)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
at _next (asyncToGenerator.js?1da1:25)
at eval (asyncToGenerator.js?1da1:32)
at new Promise (<anonymous>)
at eval (asyncToGenerator.js?1da1:21)