0👍
Don’t use arrow function to return your data and use locale
property instead of text
:
new Vue({
el: "#app",
data() {
return {
message: this.$translate.locale['hello-world']
}
},
beforeCreate() {
this.$translate.setLang('pt_BR')
},
locales: {
pt_BR: {
'hello-world': 'Olá mundo'
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-translate-plugin@1.2.0/dist/vue-translate.common.min.js"></script>
<div id="app">
<p> {{ message }} </p>
</div>
- [Vuejs]-Can't Access Object Properties In Vue
- [Vuejs]-It is impossible to access props until the hot update of the Vue JS + Quasar component occurs
0👍
I only needed to use this.t('message')
like:
<script>
export default {
data {
return {
message: this.t('message')
}
}
}
</script>
- [Vuejs]-Vue js 2 – for loop in multiple rest calls fetchData
- [Vuejs]-How to bring datepicker's dropdown panel to top in Vue.js?
0👍
It should be corrected like this with ‘$’,
export default {
data {
return {
message: this.$t('message')
}
}
}
- [Vuejs]-How to render HTML with custom components in VueJS 3 at runtime?
- [Vuejs]-How can I update data from parent component when I click child component on the vue component?
Source:stackexchange.com