vue-i18n: Uncaught TypeError: Cannot read property 'config' of undefined
Hi,
I have just copy the basic example in the Getting Started section. But I get this error message each time from this file : vue-i18n.esm.js
vue & vue-i18n version
2.1.10, 6.1.1
Basic code
import VueI18n from 'vue-i18n';
import Locales from './vue-i18n-locales.generated.js';
const messages = {
en: {
message: {
hello: 'hello world'
}
},
ja: {
message: {
hello: 'こんにちは、世界'
}
}
}
// Create VueI18n instance with options
const i18n = new VueI18n({
locale: 'ja', // set locale
messages, // set locale messages
});
Get this error message from this function
And each time I got the same error message for this code part
VueI18n.prototype._initVM = function _initVM (data) {
var silent = Vue.config.silent;
Vue.config.silent = true;
this._vm = new Vue({ data: data });
Vue.config.silent = silent;
};
Any idea ? Thanks for your help.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 23
- Comments: 16 (2 by maintainers)
Hi @gmarineau you have to do “.use” before create i18n instance:
Close (in-activity)
Ho god thank, i lost 2 hours on this issue -_-"
Thank you for your feedback! Could you provide a minimum reproruduce code with JSFiddle or JSBin or other please?
@kazupon I need to use VueI18n without installation (e.g.,
Vue.use(VueI18n)). How can I achieve it?I was getting the same error. I had this
Vue.use(Framework7Vue, Framework7, VueI18n);
then I changed it so that VueI18n is used separately and now it works…
Vue.use(Framework7Vue, Framework7); Vue.use(VueI18n);
@dbalas OK thanks. I will make a test and give you a feedback.