未验证 提交 f62f378f 编写于 作者: L Leo Caan (陈栋) 提交者: GitHub

chore: add util for install component (#707)

上级 6d5f9aa6
import type { App } from 'vue';
import { install } from '/@/utils/install';
import codeEditor from './src/CodeEditor.vue';
import jsonPreview from './src/json-preview/JsonPreview.vue';
export const CodeEditor = Object.assign(codeEditor, {
install(app: App) {
app.component(codeEditor.name, codeEditor);
},
});
export const JsonPreview = Object.assign(jsonPreview, {
install(app: App) {
app.component(jsonPreview.name, jsonPreview);
},
});
export const CodeEditor = install(codeEditor);
export const JsonPreview = install(jsonPreview);
import type { App } from 'vue';
import { install } from '/@/utils/install';
import flowChart from './src/FlowChart.vue';
export const FlowChart = Object.assign(flowChart, {
install(app: App) {
app.component(flowChart.name, flowChart);
},
});
export const FlowChart = install(flowChart);
import { App, Plugin } from 'vue';
export const install = <T>(component: T, alias?: string) => {
const C = component as any;
C.install = (app: App) => {
app.component(C.name, component);
if (alias) {
app.config.globalProperties[alias] = component;
}
};
return component as T & Plugin;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册