im using the Webpack CLI Template.
Then i install / with npm install --save vue-i18n
In my main.js i do the import and set the "en" locale
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './App'
import router from './router'
Vue.use(VueI18n)
Vue.locale('en', {})
new Vue({
el: '.nwt-mm-app',
router,
template: '<App/>',
ponents: { App }
})
The console output always says
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_vue___default.a.locale is not a function
at eval (eval at <anonymous> (app.js:802), <anonymous>:16:45)
at Object.<anonymous> (app.js:802)
at __webpack_require__ (app.js:660)
at fn (app.js:84)
at Object.<anonymous> (app.js:1176)
at __webpack_require__ (app.js:660)
at app.js:709
at app.js:712
Am i missing somewhat ? Greetings,
Markus
im using the Webpack CLI Template.
Then i install https://kazupon.github.io/vue-i18n/ with npm install --save vue-i18n
In my main.js i do the import and set the "en" locale
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './App'
import router from './router'
Vue.use(VueI18n)
Vue.locale('en', {})
new Vue({
el: '.nwt-mm-app',
router,
template: '<App/>',
ponents: { App }
})
The console output always says
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_vue___default.a.locale is not a function
at eval (eval at <anonymous> (app.js:802), <anonymous>:16:45)
at Object.<anonymous> (app.js:802)
at __webpack_require__ (app.js:660)
at fn (app.js:84)
at Object.<anonymous> (app.js:1176)
at __webpack_require__ (app.js:660)
at app.js:709
at app.js:712
Am i missing somewhat ? Greetings,
Markus
Share Improve this question edited Feb 27, 2017 at 18:46 DerMakkuz asked Feb 27, 2017 at 13:00 DerMakkuzDerMakkuz 1431 gold badge2 silver badges11 bronze badges 2- Do you have vue-i18n installed? Check if its in your package.json or node_modules folder. – peaceman Commented Feb 27, 2017 at 20:10
- Hi ... Yes it is installed as i say with npm Install --dev vue-i18n – DerMakkuz Commented Feb 27, 2017 at 20:30
2 Answers
Reset to default 5Well, You can check the author's another repo.
https://github./kazupon/vue-i18n-alpha-repro
In the demo, the vue-i18n
is like:
import Vue from 'vue'
import App from './App'
import VueI18n from 'vue-i18n'
import router from './router'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: 'ja',
messages: {
ja: {
hello: 'こんにちは'
},
en: {
hello: 'hello'
}
}
})
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
i18n,
template: '<App/>',
ponents: { App }
})
And it works.
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
// console.log(navigator.language);
let defaultLang = "zh"
const i18n = new VueI18n({
locale: defaultLang,//默认语言
messages: {
zh:{
hello:'你好',
footTitle:['现货交易','采购供应','行情资讯','个人中心']
},
en: {
hello: 'hello',
footTitle:['Spot Trading','Purchase & Supply','Market Information','Personal Center']
},
}
})
export default i18n