Итак, я пришел сегодня на работу над своим проектом, и меня смутила эта ошибка с nuxt.js.
Я удалил node_modules и папку .nuxt, переиздаю yarn install
, но у меня все еще есть эта ошибка, _vm.$t is not a function
.
Откуда это?
Я тоже получил немного _vm.localePath is not a function
...
Я убедился, что это было и в моих модулях:
modules: [
['nuxt-i18n', {
locales: [
{ code: 'en', iso: 'en-US', name:'English', file: 'en-US.json' },
{ code: 'fr', iso: 'fr-FR', name:'Français', file: 'fr.js' },
// { code: 'es', iso: 'es-ES', name:'English', file: 'es.js' }
],
defaultLocale: 'en',
// strategy: 'prefix_and_default',
lazy: true,
langDir: 'i18n/',
// By default, custom routes are extracted from page files using acorn parsing,
// set this to false to disable this
parsePages: true,
}],
...
Спасибо!
РЕДАКТИРОВАТЬ: Вот мой файл package.json:
{
"name": "myproj",
"version": "1.0.0",
"description": "My classy Nuxt.js project",
"author": "",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"build": "nuxt build",
"start": "cross-env NODE_ENV=production node server/index.js",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.2",
"@fortawesome/pro-light-svg-icons": "^5.2.0",
"@nuxtjs/axios": "^5.0.0",
"fastify": "^1.11.0",
"iview": "^3.0.1",
"koa": "^2.3.0",
"nuxt": "^1.0.0",
"nuxt-fontawesome": "^0.3.0",
"nuxt-i18n": "^5.2.1",
"pg": "^7.4.3",
"vuetify": "^1.0.19"
},
"devDependencies": {
"babel-eslint": "^8.2.1",
"cross-env": "^5.0.1",
"eslint": "^5.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-vue": "^4.0.0",
"nodemon": "^1.11.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1"
}
}
Коа и Vuetify будут заменены на fastify и iview, поэтому они здесь.
Как замечено в комментариях, nuxt является версией 1.0.0 по странной причине. Я обновил пакет до nuxt 1.4.2. У меня все еще та же проблема.
Полная трассировка стека:
Server listening on http://127.0.0.1:3000
[Vue warn]: Property or method "localePath" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <Default> at layouts/default.vue
<Root>
[Vue warn]: Error in render: "TypeError: _vm.localePath is not a function"
found in
---> <Default> at layouts/default.vue
<Root>
{ TypeError: _vm.localePath is not a function
at Proxy.render (layouts/default.vue?2d02:32:0)
at VueComponent.Vue._render (/media/drive/srv/node/ooo/node_modules/vue/dist/vue.runtime.common.js:4542:22)
at renderComponentInner (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7532:25)
at renderComponent (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7502:5)
at RenderContext.renderNode (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7418:5)
at RenderContext.next (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:2436:14)
at cachedWrite (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:2295:9)
at renderElement (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7656:5)
at renderNode (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7420:5)
at renderComponentInner (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7538:3)
at renderComponent (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7502:5)
at RenderContext.renderNode (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7418:5)
at RenderContext.next (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:2436:14)
at RenderContext.next (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:2449:12)
at cachedWrite (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:2295:9)
at renderElement (/media/drive/srv/node/ooo/node_modules/vue-server-renderer/build.js:7646:5) statusCode: 500, name: 'TypeError' }