我很难在 i18n worflow 中的 NuxtJS 中显示数据。
这是两个文件,我肯定错过了配置中的一些内容:
插件 > i18n.js:
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import axios from 'axios'
Vue.use(VueI18n, axios)
export default ({ app, store }) => {
// Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch
app.i18n = new VueI18n({
locale: store.state.locale,
fallbackLocale: 'en',
messages: {
'en': axios({
method: 'get',
url: 'https://jsonplaceholder.typicode.com/posts'
}).then((res) => { return { posts: res.data } }),
'fr': 'hello'
}
})
}
页面 > blog.vue:
<template>
<div class="Content">
<div class="container">
<ul>
<li v-for="post in posts">
{{ $t('post.title') }}
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
data: () => ({
posts: []
})
}
</script>
你能知道这个问题吗?