ts文件中使用i18n

.ts

import i18n from '../i18n';


  {
    
    
    path: '/csdn',
    name: 'CSDN',
    component: () => import(/* webpackChunkName: "csdn" */ '../views/main/csdn'),
    meta: {
    
    
      title: 'Your shopping Carts',
      topbar: {
    
    
        back: true,
        title: i18n.global.t('csdn.name'),
      },
      index: 0,
    },
  },

重点是这个! i18n.global.t('csdn.name')


然后上面引入的文件就是

import {
    
     createI18n } from 'vue-i18n';
import type {
    
     LocaleMessages, VueMessageType } from 'vue-i18n';

export default createI18n({
    
    
  legacy: false,
  locale,
  fallbackLocale: LOCALE_CODES.EN_US,
  messages: loadLocaleMessages(),
});

猜你喜欢

转载自blog.csdn.net/weixin_43814775/article/details/115331779