请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Error: no component matched

运行:http://localhost:3333/
报错内容:

> vue-todo@1.0.0 dev:server J:\vue-todo
> cross-env NODE_ENV=development node server/server.js

服务在监听0.0.0.0:3333
新的bundle生成
后台请求过程/
启动服务器时就会仅仅执行一次,比路由回调还优先
.vue局部 进入路由前
后台请求过程/bundle.f17cc3d8.js
后台请求过程/1.bundle.f17cc3d8.js
启动服务器时就会仅仅执行一次,比路由回调还优先
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)
启动服务器时就会仅仅执行一次,比路由回调还优先
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)
后台请求过程/favicon.ico
启动服务器时就会仅仅执行一次,比路由回调还优先
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)
Error: no component matched
    at server-enter.js:519:31
    at AbstractHistory.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:1851:5)
    at VueRouter.onReady (J:\vue-todo\node_modules\vue-router\dist\vue-router.common.js:2523:16)
    at server-enter.js:516:16
    at new Promise (<anonymous>)
    at module.exports../client/server-enter.js.exports.default (client/server-enter.js:5:11)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9256:43
    at new Promise (<anonymous>)
    at J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9253:14
    at Object.renderToString (J:\vue-todo\node_modules\vue-server-renderer\build.dev.js:9445:9)


server-enter.js代码:

import createApp from './create-app'


export default context =>{
    return new Promise((resolve,reject)=>{
        const {app,router}=createApp();
        router.push(context.url)
        router.onReady(()=>{
            const matchedComponents =router.getMatchedComponents()
            if(!matchedComponents.length){
               return reject(new Error('no component matched'))
            }
            resolve(app)
        })
    })
}

create-app.js代码:

import Vue from 'vue'
import Vuex from 'vuex'
import App from './app.vue'
import VueRouter from 'vue-router'


import createRoute from './routers/router'
import createStore from './store/store'
require('./assets/styles/global.css')


Vue.use(VueRouter);
Vue.use(Vuex);

export default ()=>{
    const router=createRoute()
    const store=createStore()

    const app=new Vue({
        router,
        store,
        render:h=>h(App)
    });

    return {app,router,store}
}

正在回答 回答被采纳积分+3

1回答

Jokcy 2019-02-20 22:04:40

你把服务端所有信息贴出来,尤其是报错的路由,这应该就是类似js请求进入到服务端渲染的流程里的原因,如果是这种情况,那么就是koa的static中间件没有配置好的原因。

0 回复 有任何疑惑可以回复我~
  • 提问者 慕圣5285355 #1
    服务端错误信息我,重新补上了。那些中文是我在生命周期加上的console,应该不会影响吧
    回复 有任何疑惑可以回复我~ 2019-02-21 00:26:53
  • Jokcy 回复 提问者 慕圣5285355 #2
    启动服务器时就会仅仅执行一次,比路由回调还优先   这个信息是什么时候打印出来的?从现在的信息来看,就是你的js请求进入到了服务端渲染的处理函数里面,你可以在服务端渲染的处理函数里面打印一下路径看看是不是有js请求的路由进来了。
    回复 有任何疑惑可以回复我~ 2019-02-21 18:25:12
  • 老师,可以麻烦您说的详细一点嘛,我也遇到了同样的问题,研究好久了还没有解决。。。
    回复 有任何疑惑可以回复我~ 2020-02-17 16:18:48
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信