diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 2f575c8e7..011408e92 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -16,6 +16,10 @@ - 独立出`vite-plugin-html`,并修改相关插入 html 的逻辑 +### 🐛 Bug Fixes + +- 修复热更新时多次注册组件警告问题 + ## 2.0.0-rc.5 (2020-10-26) ### ✨ Features diff --git a/src/App.vue b/src/App.vue index 92b6a4823..1059d2b20 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,7 +20,7 @@ moment.locale('zh-cn'); export default defineComponent({ - name: 'App', + name: 'App1', components: { ConfigProvider }, setup() { useInitAppConfigStore(); diff --git a/src/components/registerGlobComp.ts b/src/components/registerGlobComp.ts index 15c283174..e0561e032 100644 --- a/src/components/registerGlobComp.ts +++ b/src/components/registerGlobComp.ts @@ -5,8 +5,13 @@ import { Button as AntButton } from 'ant-design-vue'; import { getApp } from '/@/useApp'; const compList = [Icon, BasicHelp, BasicTitle, Button, AntButton.Group]; + +// Fix hmr multiple registered components +let registered = false; export function registerGlobComp() { + if (registered) return; compList.forEach((comp: any) => { getApp().component(comp.name, comp); }); + registered = true; }