UNPKG

fe-builder

Version:
29 lines (21 loc) 551 B
import Router from './router.js'; class App { constructor() { this.getRoute(); } getRoute(){ let ctrl = Router.getController(window.location.pathname); this.launchController(ctrl); } async launchController(ctrl){ if(!ctrl) return; const file = await import('./controllers/' + ctrl + '.ctrl.js'), controller = file.default; if(controller){ new controller(); } } } window.addEventListener('DOMContentLoaded', function(){ new App(); });