Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template 标签中使用router-view报错 #16

Open
K-walker opened this issue Aug 21, 2017 · 2 comments
Open

template 标签中使用router-view报错 #16

K-walker opened this issue Aug 21, 2017 · 2 comments

Comments

@K-walker
Copy link

你好,我想向您请教一个问题,就是我在template标签中使用router-view会报错:
Failed to mount component:template or render function not defined .
但是把router-view去掉就又正常了,您知道是为什么吗?

App.vue

<template>
  <div id="app">
    <div class="top">
      <ul>
          <li>用户管理系统</li>
          <li>退出</li>
          <li>{{accountName}}</li>
      </ul>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        accountName: 'Admin'
      }
    }
  }
</script>

路由

export default new Router({
  routes: [
      {
        path:'/'
      },
      {
        path: '/hello',
        component: Hello
      },
      {
        path: '/list',
        component: UserList
      }
  ]
})

main.js

new Vue({
  el: '#app', 
  router, 
  render:h => h(App)
}).$mount('#app')
@xrr2016
Copy link
Owner

xrr2016 commented Aug 21, 2017

 routes: [
      {
        path: '/',
        component: 'Your main component'
      },
     ......
  ]

@K-walker
Copy link
Author

我已经解决了,我在 ./router/index.js 中导入组件的方式错了 const Comp = import('./component/comp') 这样导入就会报错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants