From 33d431606de544bb3d57e2107e0977554af0092a Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Tue, 19 Mar 2019 15:36:47 +0800 Subject: [PATCH] Allow loading pure script --- resources/assets/src/index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/resources/assets/src/index.js b/resources/assets/src/index.js index c635a8ef..3e8cc2ba 100644 --- a/resources/assets/src/index.js +++ b/resources/assets/src/index.js @@ -13,20 +13,24 @@ if (process.env.NODE_ENV === 'development') { setTimeout(langs.find(({ lang }) => lang === blessing.locale).load, 0) } -(() => { +{ const route = routes.find( // eslint-disable-next-line no-shadow route => (new RegExp(`^${route.path}$`, 'i')).test(blessing.route) ) if (route) { - Vue.prototype.$route = (new RegExp(`^${route.path}$`, 'i')).exec(blessing.route) - // eslint-disable-next-line no-new - new Vue({ - el: route.el, - mounted() { - setTimeout(() => emitter.emit('mounted', { el: route.el }), 100) - }, - render: h => h(route.component), - }) + if (route.component) { + Vue.prototype.$route = (new RegExp(`^${route.path}$`, 'i')).exec(blessing.route) + // eslint-disable-next-line no-new + new Vue({ + el: route.el, + mounted() { + setTimeout(() => emitter.emit('mounted', { el: route.el }), 100) + }, + render: h => h(route.component), + }) + } else if (route.script) { + route.script() + } } -})() +}