committed by
GitHub
3 changed files with 17 additions and 18 deletions
@ -1,15 +1,6 @@ |
|||
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); |
|||
|
|||
@ -1,8 +1,4 @@ |
|||
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); |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
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; |
|||
}; |
|||
Loading…
Reference in new issue