0👍
✅
require.ensure
is the legacy Webpack syntax, which is superceded by import
. And as @Phil pointed out, resolve => {/*...*/}
itself does not create a Promise
, which is needed for lazy loading routes. You probably meant something like this:
const foo = new Promise(resolve => {
require.ensure( './path/to/foo', () => resolve(require('./path/to/foo')) );
});
const routes = [
{
path: '/foo',
component: foo
}
];
However, the vue-router docs recommends the import
syntax for lazy loading routes:
const routes = [
{
path: '/foo',
component: () => import('./path/to/foo')
}
];
Source:stackexchange.com