vuejs / vue2-ssr-docs

Vue.js Server-Side Rendering Guide (for Vue 2)
565 stars 239 forks source link

同一个node服务中创建两个createRenderer在不同路由执行时会报错,怎么解? #312

Open shinelp100 opened 3 years ago

shinelp100 commented 3 years ago

想要在同一个node服务中针对不同路由规则渲染不同template模板(layout模板),于是创建两个createRenderer方法做缓存,但是只要有一个createRenderer 的执行后,另个一肯定会报错。如下:

renderer: TypeError: Cannot redefine property: $router at Function.defineProperty () 0|pcsearch | at Function.X [as install] (server-bundle.js:2:142707) 0|pcsearch | at Function.Vue.use (/Users/yangjie/work/haodf/eureka/pcsearch/node_modules/vue/dist/vue.runtime.common.dev.js:5087:22) 0|pcsearch | at Object. (server-bundle.js:2:130989) 0|pcsearch | at n (server-bundle.js:2:124) 0|pcsearch | at Object. (server-bundle.js:2:111415) 0|pcsearch | at n (server-bundle.js:2:124) 0|pcsearch | at Object. (server-bundle.js:2:99009) 0|pcsearch | at n (server-bundle.js:2:124) 0|pcsearch | at Object. (server-bundle.js:2:98767) 0|pcsearch | at n (server-bundle.js:2:124) 0|pcsearch | at Object. (server-bundle.js:2:98461) 0|pcsearch | at n (server-bundle.js:2:124) 0|pcsearch | at server-bundle.js:2:1055 0|pcsearch | at Object. (server-bundle.js:2:1066) 0|pcsearch | at evaluateModule (/Users/yangjie/work/haodf/eureka/pcsearch/node_modules/vue-server-renderer/build.dev.js:9318:21)