Skip to content

Commit

Permalink
fix(docs): config-provider example (element-plus#8534)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jun 30, 2022
1 parent dc5ea23 commit 77fa19b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

declare module '@vue/runtime-core' {
Expand Down
37 changes: 12 additions & 25 deletions docs/examples/config-provider/usage.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
<template>
<div>
<el-button m="b-2" @click="toggle"> Switch Lang </el-button>
<el-button mb-2 @click="toggle">Switch Language</el-button>
<br />
<el-config-provider :locale="locale2">
<el-color-picker :model-value="''" style="vertical-align: middle" />

<el-config-provider :locale="locale">
<el-table mb-1 :data="[]" />
<el-pagination :total="100" />
</el-config-provider>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { computed, ref } from 'vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'
const language = ref('zh-cn')
const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en))
const locale1 = ref({
name: 'zh-cn',
el: {
colorpicker: {
confirm: '确定',
clear: '清空',
},
},
})
const locale2 = ref({
name: 'en',
el: {
colorpicker: {
confirm: 'Confirm',
clear: 'Clear',
},
},
})
const toggle = () => {
const temp = locale1.value
locale1.value = locale2.value
locale2.value = temp
language.value = language.value === 'zh-cn' ? 'en' : 'zh-cn'
}
</script>

0 comments on commit 77fa19b

Please sign in to comment.