W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
Config Provider 被用來提供全局的配置選項,讓你的配置能夠在全局都能夠被訪問到,Config Provider 使用了 Vue 的 provide/inject 特性
<template> <el-config-provider :locale="locale"> <app /> </el-config-provider> </template> <script> import { defineComponent } from 'vue' import { ElConfigProvider } from 'element-plus' import zhCn from 'element-plus/lib/locale/lang/zh-cn' export default defineComponent({ components: { ElConfigProvider, }, setup() { return { locale: zhCn, } }, }) </script>
<template>
<div>
<el-config-provider :locale="locale1">
<div style="margin: 8px;">
<el-empty />
</div>
<div style="margin: 8px;">
<el-transfer />
</div>
</el-config-provider>
<el-button @click="toggle" style="margin-left: 8px; vertical-align: middle;">
切換語言
</el-button>
</div>
</template>
<script>
import { ref } from 'vue'
// import { ConfigProvider } from 'element-plus'
export default {
setup() {
const locale1 = ref({
name: 'zh-cn',
el: {
table: {
emptyText: '無數(shù)據(jù)',
},
transfer: {
titles: ['列表1', '列表2'],
noData: '無數(shù)據(jù)',
},
},
})
const locale2 = ref({
name: 'en',
el: {
table: {
emptyText: 'no data',
},
transfer: {
titles: ['list 1', 'list 2'],
noData: 'no data',
},
},
})
const toggle = () => {
const temp = locale1.value
locale1.value = locale2.value
locale2.value = temp
}
return {
locale1,
locale2,
toggle,
}
},
}
</script>
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
locale | 翻譯文本對象 | Object<Language> | languages | English |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: