diff --git a/packages/@vuepress/theme-default/global-components/CodeGroup.vue b/packages/@vuepress/theme-default/global-components/CodeGroup.vue index ac6ec55436..6051ab3da0 100644 --- a/packages/@vuepress/theme-default/global-components/CodeGroup.vue +++ b/packages/@vuepress/theme-default/global-components/CodeGroup.vue @@ -45,10 +45,16 @@ export default { }, mounted () { this.loadTabs() + this.$root.$on('changeAllCodeTab', (index) => { + if (this.activeCodeTabIndex !== index) { + this.changeCodeTab(index) + } + }) }, methods: { changeCodeTab (index) { this.activeCodeTabIndex = index + this.$root.$emit('changeAllCodeTab', index) }, loadTabs () { this.codeTabs = (this.$slots.default || []).filter(slot => Boolean(slot.componentOptions)).map((slot, index) => {