mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
20 lines
555 B
Vue
20 lines
555 B
Vue
<script>
|
|
export default {
|
|
watch: {
|
|
'$i18n.locale': function () {
|
|
// console.log('locale change')
|
|
}
|
|
},
|
|
render (h, context) {
|
|
const locale = this.$i18n.locale
|
|
const defaultSlot = (this.$scopedSlots.default && this.$scopedSlots.default()) || []
|
|
const index = defaultSlot.findIndex(VNode => VNode.componentOptions.tag === locale)
|
|
// console.log(locale, defaultSlot[0].componentOptions.tag)
|
|
// console.log(index)
|
|
if (~index) {
|
|
return defaultSlot[index]
|
|
} else return defaultSlot[0] || null
|
|
}
|
|
}
|
|
</script>
|