5)再次访问http://local.test.com:7001/ 报错
2020-12-15 13:49:19,015 ERROR 54504 [-/127.0.0.1/-/23ms GET /] nodejs.TypeError: Cannot read property 'matched' of undefined
at render (/Users/haha/work/test/demo1/node_modules/vue-router/dist/vue-router.common.js:356:25)
at createFunctionalComponent (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3052:30)
at createComponent (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3225:12)
at _createElement (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3415:15)
at createElement (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3347:10)
at vm._c (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3484:42)
at Proxy.render (webpack:///./app/web/component/layout/admin/content/index.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options:12:8)
at Vue._render (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3538:22)
at resolve (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8656:28)
at waitForServerPrefetch (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8287:3)
at render (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8658:5)
at Object.renderToString (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:9183:9)
at /Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:137:21
at new Promise ()
at Engine.renderString (/Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:136:12)
at Engine.renderClient (/Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:155:17)
What happens?
复现步骤 1、使用easywebpack cli,初始化一个项目 1)全局安装easywebpack 2)easywebpack init,初始化一个项目,如下图
3)修改admin.ts的代码,ctx.ssr的状态可以由接口动态的控制,自行实现(比如使用自定义的cookie)
2、启动服务 npm run dev
3)访问http://local.test.com:7001/ 走的是renderClient方法(因为ctx.ssr默认是undefined)
4)访问http://local.test.com:7001/admin
5)再次访问http://local.test.com:7001/ 报错 2020-12-15 13:49:19,015 ERROR 54504 [-/127.0.0.1/-/23ms GET /] nodejs.TypeError: Cannot read property 'matched' of undefined at render (/Users/haha/work/test/demo1/node_modules/vue-router/dist/vue-router.common.js:356:25) at createFunctionalComponent (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3052:30) at createComponent (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3225:12) at _createElement (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3415:15) at createElement (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3347:10) at vm._c (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3484:42) at Proxy.render (webpack:///./app/web/component/layout/admin/content/index.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options:12:8) at Vue._render (/Users/haha/work/test/demo1/node_modules/vue/dist/vue.runtime.common.dev.js:3538:22) at resolve (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8656:28) at waitForServerPrefetch (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8287:3) at render (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:8658:5) at Object.renderToString (/Users/haha/work/test/demo1/node_modules/vue-server-renderer/build.dev.js:9183:9) at /Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:137:21 at new Promise ()
at Engine.renderString (/Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:136:12)
at Engine.renderClient (/Users/haha/work/test/demo1/node_modules/egg-view-vue-ssr/lib/engine.js:155:17)
Context