vue3国际化语言包在js文件中的使用
文章目录
main.tsapp.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>模板中使用
<div>{{$t('message')}}</div>
<el-input v-model="value" :placeholder="$t('inputPlaceholder')" />
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论