Skip to content

Commit

Permalink
fix: 修复两个组件引入通一子组件热更新报错问题
Browse files Browse the repository at this point in the history
将插入components改为插入函数
  • Loading branch information
yuntian001 committed Sep 23, 2022
1 parent f292910 commit add16a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions plugin/vueSetupExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export function supportScript(code: string, options: ExtendOptions) {
attrs.langImport = `{{${langImport}}}`;
}
}
if (options.setComponents) {
if (options.setComponents && !attrs.getComponents) {
const components = getComponent(descriptor);
if (components.length) {
attrs.components = `{{[${components}]}}`;
attrs.getComponents = `{{()=>[${components}]}}`;
}
}
let scriptStr = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
</template>
<script setup lang="ts" name="Right">
import { localeConfig } from '@/config';
import MeDarkSwitch from '@/components/meDarkSwitch.vue';
import MeLocaleSelect from '@/components/meLocaleSelect.vue';
import MeSizeSelect from '@/components/meSizeSelect.vue';
import MessageBox from './components/messageBox.vue';
import { useSettingStore } from '@/store';
import User from './components/user.vue';
Expand Down
5 changes: 5 additions & 0 deletions src/locales/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export const useLoadMessages = () => {
loadMessages(component as ComponentOptions, isLoading, locale, importArr);
});
}
if ((<ComponentOptions>options).getComponents) {
(<ComponentOptions>options).getComponents().forEach((component: ComponentOptions) => {
loadMessages(component, isLoading, locale, importArr);
});
}
if ((<ComponentOptions>options).langImport) {
const res = loadMessage((<ComponentOptions>options).langImport!, locale, isLoading);
if (res instanceof Promise) {
Expand Down

0 comments on commit add16a9

Please sign in to comment.