Closed chenzhiguo closed 7 years ago
Uhhh, System.import
is like not a thing in Electron? Why can'y you just either use require
which you indicate works or use import Thing from './here';
at the top of the file?
@MarshallOfSound Just to lazyload the *.vue file. If use require or import, will the file be loaded immediately?
@chenzhiguo Why do you want to lazy load it though? You aren't loading the component over HTTP, there is no file size concern here. It's literally just reading a file from the local filesystem. Lazy loading for Electron apps makes no sense?
Aha...I feel you are very reasonable, you are convinced. But, if I want use it, Is required to use webpack? Do you know this one? @MarshallOfSound
@chenzhiguo If you realllllyyyy want to lazy load even if you're literally just loading a local file 😕
You can just wrap require
in a function so it isn't called immediately.
component: () => require('./components/Login.vue')
YOU guys are so funny ! lol (commented by a guy who is looking for solution of vue-router in eletron)
The project is created by
electron-forge init demo --template=vue
Only vue + vue-router, I use the many method to lazyload vue component, but has error:**1. Lazy load must rely on webpack? Has the electron-forge include it?
Vue.use(Router);
let router = new Router({ routes: [ { path: '/', redirect: '/index' }, { name: 'login', path: '/login', // component: require('./components/Login.vue') //working // component: resolve => System.import('./components/Login.vue') //not working // component: () => import('./components/Login.vue') //not working component: view('Login') //not working }, { name: 'test', path: '/test/:userId', component: resolve => require(['./components/Test.vue'], resolve) //not working }, { path: '*', redirect: '/' } ] });
/**
export default router;