Answer the question
In order to leave comments, you need to log in
How to use variables in Vue template?
I want to use i18n
https://github.com/Haixing-Hu/vue-i18n
I wrote in main.js file
var Vue = require('vue');
var i18n = require('vue-i18n');
Vue.use(i18n, {
baseUrl: 'resources/i18n'
});
new Vue({
el: '#test-i18n',
beforeCompile: function() {
this.$setLanguage("zh-CN");
},
methods: {
switchLanguage: function(lang) {
this.$setLanguage(lang);
}
}
});
<div id="test-i18n" class="message">
<p>Language: {{$language}}</p>
<p>{{$i18n.message.hello}}, {{$i18n.message.world}}</p>
</div>
Answer the question
In order to leave comments, you need to log in
beforeCompile:
I think the problem is the version mismatch between Vue and the plugin https://github.com/Haixing-Hu/vue-i18n.
There are more recent packages for internationalization, such as https://kazupon.github.io/vue-i18n/ .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question