vue-i18n / general / Translation
类型别名: Translation()
ts
type Translation = () => object;翻译组件
返回值
object
$props
ts
$props: VNodeProps & TranslationProps;备注
有关属性的详细信息,请参见以下项目:
示例
html
<div id="app">
<!-- ... -->
<i18n keypath="term" tag="label" for="tos">
<a :href="url" target="_blank">{{ $t('tos') }}</a>
</i18n>
<!-- ... -->
</div>js
import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
const messages = {
en: {
tos: 'Term of Service',
term: 'I accept xxx {0}.'
},
ja: {
tos: '利用規約',
term: '私は xxx の{0}に同意します。'
}
}
const i18n = createI18n({
locale: 'en',
messages
})
const app = createApp({
data: {
url: '/term'
}
}).use(i18n).mount('#app')