|
1 | | -import Vue from 'vue'; |
| 1 | +// import Vue from 'vue'; |
2 | 2 | import router, { addRoutes, lazyLoadView } from './router'; |
3 | 3 | import store from './store'; |
4 | 4 | import ModuleLoader from '@vue-async/module-loader'; |
@@ -28,21 +28,65 @@ addRoutes([ |
28 | 28 | name: 'remote-component-b', |
29 | 29 | component: () => lazyLoadView(app.$componentLoader('componentB', '/static/componentB/componentB.umd.min.js')), |
30 | 30 | }, |
| 31 | + { |
| 32 | + path: 'wrong-component-name', |
| 33 | + name: 'wrong-component-name', |
| 34 | + component: () => |
| 35 | + lazyLoadView(app.$componentLoader('wrongComponentName', '/static/componentB/componentB.umd.min.js')), |
| 36 | + }, |
| 37 | + { |
| 38 | + path: 'wrong-component-entry', |
| 39 | + name: 'wrong-component-entry', |
| 40 | + component: () => |
| 41 | + lazyLoadView(app.$componentLoader('entry', 'http://www.xx.com/static/componentB/errorComponent.umd.min.js')), |
| 42 | + }, |
31 | 43 | ]); |
32 | 44 |
|
33 | 45 | app |
34 | | - .$moduleLoader({ |
35 | | - dymanicRouter: '/static/dymanicRouter/dymanicRouter.umd.min.js', |
36 | | - // page 异步加载,样式限 page load 加载出来 |
37 | | - // dymanicRouter: { |
38 | | - // entry: '/static/dymanicRouter/dymanicRouter.umd.min.js', |
39 | | - // css: ['/static/dymanicRouter/css/1.281753bd.css', '/static/dymanicRouter/css/2.2b65cb29.css'], |
40 | | - // }, |
41 | | - dymanicComponent: { |
42 | | - entry: '/static/dymanicComponent/dymanicComponent.umd.min.js', |
43 | | - css: '/static/dymanicComponent/dymanicComponent.css', |
| 46 | + .$moduleLoader( |
| 47 | + [ |
| 48 | + { |
| 49 | + dymanicRouter: '/static/dymanicRouter/dymanicRouter.umd.js', |
| 50 | + // page 异步加载,样式限 page load 加载出来 |
| 51 | + // dymanicRouter: { |
| 52 | + // entry: '/static/dymanicRouter/dymanicRouter.umd.min.js', |
| 53 | + // css: ['/static/dymanicRouter/css/1.281753bd.css', '/static/dymanicRouter/css/2.2b65cb29.css'], |
| 54 | + // }, |
| 55 | + dymanicComponent: { |
| 56 | + entry: '/static/dymanicComponent/dymanicComponent.umd.min.js', |
| 57 | + styles: '/static/dymanicComponent/dymanicComponent.css', |
| 58 | + }, |
| 59 | + }, |
| 60 | + { |
| 61 | + // 同名 |
| 62 | + moduleName: 'dymanicComponent', |
| 63 | + entry: '/static/dymanicComponentCopy/dymanicComponent.umd.min.js', |
| 64 | + styles: '/static/dymanicComponentCopy/dymanicComponent.css', |
| 65 | + }, |
| 66 | + { |
| 67 | + // 错误 module name (执行正常) |
| 68 | + moduleName: 'wrongName', |
| 69 | + entry: '/static/dymanicComponentCopy/dymanicComponent.umd.min.js', |
| 70 | + }, |
| 71 | + { |
| 72 | + // 错误 entry (执行 error) |
| 73 | + moduleName: 'wrongEntry', |
| 74 | + entry: 'http://www.xx.com/error.umd.min.js', |
| 75 | + }, |
| 76 | + // fn |
| 77 | + // (Vue: any) => { |
| 78 | + // console.log(Vue); |
| 79 | + // }, |
| 80 | + ], |
| 81 | + { |
| 82 | + success: () => { |
| 83 | + app.$mount('#app'); |
| 84 | + }, |
| 85 | + error(msg, module) { |
| 86 | + console.warn(msg, module); |
| 87 | + }, |
44 | 88 | }, |
45 | | - }) |
| 89 | + ) |
46 | 90 | .then(() => { |
47 | | - app.$mount('#app'); |
| 91 | + // then won't exec when success is set in options |
48 | 92 | }); |
0 commit comments