Commit 7a6181e8c72cd110cdfc09f624f8be43e76ef74c
1 parent
a1b9902b
fix: hmr multiple registered components
Showing
3 changed files
with
10 additions
and
1 deletions
CHANGELOG.zh_CN.md
src/App.vue
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | moment.locale('zh-cn'); | 20 | moment.locale('zh-cn'); |
21 | 21 | ||
22 | export default defineComponent({ | 22 | export default defineComponent({ |
23 | - name: 'App', | 23 | + name: 'App1', |
24 | components: { ConfigProvider }, | 24 | components: { ConfigProvider }, |
25 | setup() { | 25 | setup() { |
26 | useInitAppConfigStore(); | 26 | useInitAppConfigStore(); |
src/components/registerGlobComp.ts
@@ -5,8 +5,13 @@ import { Button as AntButton } from 'ant-design-vue'; | @@ -5,8 +5,13 @@ import { Button as AntButton } from 'ant-design-vue'; | ||
5 | import { getApp } from '/@/useApp'; | 5 | import { getApp } from '/@/useApp'; |
6 | 6 | ||
7 | const compList = [Icon, BasicHelp, BasicTitle, Button, AntButton.Group]; | 7 | const compList = [Icon, BasicHelp, BasicTitle, Button, AntButton.Group]; |
8 | + | ||
9 | +// Fix hmr multiple registered components | ||
10 | +let registered = false; | ||
8 | export function registerGlobComp() { | 11 | export function registerGlobComp() { |
12 | + if (registered) return; | ||
9 | compList.forEach((comp: any) => { | 13 | compList.forEach((comp: any) => { |
10 | getApp().component(comp.name, comp); | 14 | getApp().component(comp.name, comp); |
11 | }); | 15 | }); |
16 | + registered = true; | ||
12 | } | 17 | } |