我们正在设计一个插件架构,并且很好奇是否有办法允许通过 URL 将 3rd 方插件作为 Vue 组件包含在内。
如何从远程 url 导入 vue 文件?例如,我试图按照 Alex Jover Morales 的方法来导入异步组件Async vue.js components。在这种方法中,当用户单击“导入插件”按钮时,应该会出现一个从 url 导入的 vue 组件。我在 github 页面上发布了我想导入的 vue 组件。
该应用程序无法解析该网址。为什么不?我必须做些什么来解决这个问题? 导入错误
这是我正在导入的 vue 组件的代码...
<div v-if="showPlugin">
<MassEmailerPlugin>
</MassEmailerPlugin>
<button @click.prevent="addPlugin">Add Plugin</button>
</div>
</template>
<style>
</style>
<script>
export default {
name: "Plugins",
components: {
MassEmailerPlugin: () => import('https://github.com/gideongrossmanHome/test-vuejs-plugin/blob/master/index.html')
},
data() {
return {
showPlugin: false
}
},
methods: {
addPlugin() {
this.showPlugin = true;
console.log("showing plugin");
}
}
};
</script>
这是我要导入的组件...
<template>
<div>
Plugin from url
</div>
</template>
<script>
export default {
name: "MassEmailerPlugin"
}
</script>