feat(i18n): 添加国际化消息支持,更新首页组件以显示重要消息
This commit is contained in:
@ -17,7 +17,16 @@ definePage({
|
|||||||
import type { FunctionalComponent } from 'vue';
|
import type { FunctionalComponent } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const { locale } = useI18n();
|
const { locale, t } = useI18n({
|
||||||
|
messages: {
|
||||||
|
en: {
|
||||||
|
message: 'This is an important message!',
|
||||||
|
},
|
||||||
|
zh: {
|
||||||
|
message: '这是一条重要消息!',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// https://cn.vuejs.org/guide/extras/render-function#typing-functional-components
|
// https://cn.vuejs.org/guide/extras/render-function#typing-functional-components
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
@ -47,6 +56,7 @@ const FComponent: FunctionalComponent<{ prop: string }> = (props, context) => (
|
|||||||
</select>
|
</select>
|
||||||
<h1>{{ $t('welcome') }}</h1>
|
<h1>{{ $t('welcome') }}</h1>
|
||||||
<p>{{ $t('hello', { name: 'John' }) }}</p>
|
<p>{{ $t('hello', { name: 'John' }) }}</p>
|
||||||
|
<p class="message">{{ t('message') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FComponent prop="Hello World" style="margin-top: 8px"></FComponent>
|
<FComponent prop="Hello World" style="margin-top: 8px"></FComponent>
|
||||||
|
Reference in New Issue
Block a user