Added support for loading extension Web Components
This commit is contained in:
parent
0a1b138bcb
commit
9c309fc791
6 changed files with 108 additions and 46 deletions
61
src/components/pluginComponents/WebComponentLoader.vue
Normal file
61
src/components/pluginComponents/WebComponentLoader.vue
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="error" class="uk-padding-small uk-text-danger">
|
||||
<b>{{ error }}</b>
|
||||
</div>
|
||||
<component
|
||||
:is="componentName"
|
||||
v-if="ready"
|
||||
:component-base-u-r-l="ApiRootURL"
|
||||
></component>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "WebComponentLoader",
|
||||
|
||||
props: {
|
||||
componentURL: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
componentName: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
ready: false,
|
||||
error: null
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
ApiRootURL: function() {
|
||||
return `${this.$store.getters.baseUri}/api/v2`;
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// Method 2
|
||||
this.$loadScript(this.componentURL)
|
||||
.then(() => {
|
||||
const el = customElements.get(this.componentName);
|
||||
if (el) {
|
||||
this.ready = true;
|
||||
} else {
|
||||
this.error = `Error: No component ${this.componentName} found.`;
|
||||
}
|
||||
this.ready = true;
|
||||
})
|
||||
.catch(() => {
|
||||
this.ready = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue