How to internationalize js files in vue using i18n

in my vue project static/js/country_region.js this file is imported into a .vue file to be used as a drop-down list

but my website is multilingual, all introduced i18n, but $t () this syntax can only be used in .vue, how can I use it in this js file

import Vue from "vue";
import store from "../../src/vuex/store"
export default [
  {value: "0",label: Vue.$t("passport.authing")},
  {value: "London",label: "London"},
  {value: "Sydney",label: "Sydney"},
  {value: "Ottawa",label: "Ottawa"},
  {value: "Paris",label: "Paris"},
  {value: "Canberra",label: "Canberra"}
]

if I write this, I will report an error


import i18n from 'i18n'
i18n.t ('.')
try


if you write this, you need to wrap it up, assign it to a variable directly in the new Vue of main.js, and then obtain it from the variable.
such as
window.vm= new Vue ({
/ / separate js in main.js,
{value: '0percent, Label: window.vm.$i18n.t ('passport.authing')}
import Vue from' vue' is not needed.


you can!

Menu