关于vue3:vue3国际化语言包在js文件中的使用

8次阅读

共计 271 个字符,预计需要花费 1 分钟才能阅读完成。

main.ts
app.use(i18n)

js 中应用

<script setup lang="ts">
import {getCurrentInstance, ComponentInternalInstance} from "vue"

const {appContext} = getCurrentInstance() as ComponentInternalInstance

let msg = appContext.config.globalProperties.$t("message")
console.log(msg)
</script>

模板中应用
$t('message')

正文完
 0