使用vue3-sfc-loader 的loadModule 函数来加载这个字符串内容。这个函数允许你传递一个对象,其中包含一个 content 属性,该属性包含你的 Vue 组件字符串。 javascript import { loadModule } from 'vue3-sfc-loader'; loadModule({ content: vueComponentString, filename: 'MyComponent.vue' // 可选,但建议提供一...
head.insertBefore(style, ref); }, } const { loadModule } = window['vue3-sfc-loader']; const app = Vue.createApp({ components: { 'my-component': Vue.defineAsyncComponent( () => loadModule('./myComponent.vue', options) ) }, template: '<my-component></my-component>' }); app....
而不是 import{ loadModule }from'vue3-sfc-loader' 3|0研发 现阶段就是寻找方案阶段,还没有精力用这个包,先放这里记录一下。 4|0附录 远程vue文件加载器 — vue3-sfc-loader https://www.jianshu.com/p/f1908b6ef519 https://github.com/FranckFreiburger/vue3-sfc-loader https://www.npmjs.com/pa...
}const{ loadModule } =window['vue3-sfc-loader'];constapp = Vue.createApp({components: {'my-component': Vue.defineAsyncComponent(()=>loadModule('./myComponent.vue', options) ) },template:'<my-component></my-component>'}); app.mount('#app'); More Examples seeall examples Try It Onl...
import { loadModule } from "vue3-sfc-loader/dist/vue3-sfc-loader.js";//重要 let data = reactive({ remote: null, temp: "", options: { moduleCache: { vue: Vue, }, // 获取文件 async getFile(url: any) { const res = await fetch(url).then((response) => response.text()); ...
1. 而不是 import { loadModule } from 'vue3-sfc-loader' 1. 研发 现阶段就是寻找方案阶段,还没有精力用这个包,先放这里记录一下。 附录 远程vue文件加载器 — vue3-sfc-loader https://www.jianshu.com/p/f1908b6ef519 ...
loadModule ▸loadModule(path,options?):Promise<ModuleExport> This is the main function. This function is intended to be used only to load the entry point of your application. If for some reason you need to use it in your components, be sure to share at least the options.moduleCacheobject...
loadModule(path: string, options: Options): Promise<VueComponent> dist/ npm install vue3-sfc-loader jsDelivr CDN: https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js UNPKG CDN: https://unpkg.com/vue3-sfc-loader esm version: dist/vue3-sfc-loader.esm.js umd version:...
loadModule ▸loadModule(path:AbstractPath,options?:Options): Promise<ModuleExport> Defined inindex.ts:152 This is the main function. This function is intended to be used only to load the entry point of your application. If for some reason you need to use it in your components, be sure to...
resolve(sfcContent); }, addStyle: () => {}, } const { loadModule } = window["vue3-sfc-loader"]; Vue.createApp(Vue.defineAsyncComponent(() => loadModule('/myPugComponent.vue', options))).mount('#app'); open in JSBin ▶🔝Using...