From 1552fa3ba9bde9d9d88d5d7c858943e746e784ef Mon Sep 17 00:00:00 2001 From: yanran200730 Date: Wed, 2 Mar 2022 14:07:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=8F=A3=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/entries.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/entries.js diff --git a/examples/entries.js b/examples/entries.js new file mode 100644 index 00000000..52683155 --- /dev/null +++ b/examples/entries.js @@ -0,0 +1,22 @@ +//引入当前工程所有的应用 +const install = function(Vue) { + if (install.installed) return Promise.resolve(); + else { + let contexts = require.context('../project/shandong10086/apps', true, /(\/.+)\/App[^\/]+\.vue$/); + if (contexts) { + contexts.keys().map((e) => { + if (contexts(e).default) { + Vue.component(contexts(e).default.name, contexts(e).default); + } + }); + } + } +}; +// 判断是否是直接引入文件 +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue); +} +export default { + // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 + install +};