Skip to content

Commit

Permalink
fix: hmr multiple registered components
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 27, 2020
1 parent a1b9902 commit 7a6181e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

- 独立出`vite-plugin-html`,并修改相关插入 html 的逻辑

### 🐛 Bug Fixes

- 修复热更新时多次注册组件警告问题

## 2.0.0-rc.5 (2020-10-26)

### ✨ Features
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
moment.locale('zh-cn');
export default defineComponent({
name: 'App',
name: 'App1',
components: { ConfigProvider },
setup() {
useInitAppConfigStore();
Expand Down
5 changes: 5 additions & 0 deletions src/components/registerGlobComp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 7a6181e

Please sign in to comment.