Use i18n in ts file

.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,
    },
  },

The point is this! i18n.global.t('csdn.name')


Then the file introduced above is

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(),
});

Guess you like

Origin blog.csdn.net/weixin_43814775/article/details/115331779