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

I tried to build a vue project with parcel and now fails……or said, I got some error #229

Closed
wqcstrong opened this issue Dec 12, 2017 · 12 comments

Comments

@wqcstrong
Copy link

I just tried to build a vue project and set the directory structure to be similar to the vue-cli generated project. And I got some error after just used vue-router function.
The error is:

[vue-router] route config "component" for path: / cannot be a string id. Use an actual component instead.

Following is my directory structure :

- Parcel
   - node_modules
   - src
      - components
         - Index.vue
      - router
         - index.js
      - App.vue
      - main.js
   - index.html
   - package.json

In order to see more clearly, I wrote out part of the source code demo:

  • index.html :
<body>
    <div id="app"></div>
    <script src="./src/main.js"></script>
</body>
  • src/main.js
import Vue from 'vue'
import router from './router/index.js'
import App from './App.vue'

Vue.config.productionTip = false
new Vue({
    el: "#app",
    router,
    template: '<App/>',
    components: { App }
})
  • src/App.vue:
<template>
    <div id="app">
        <h1>App Page</h1>
        <router-view></router-view>
    </div>
</template>
  • router/index.js
import Vue from 'vue'
import Router from 'vue-router'
import Index from '../components/Index.vue'

Vue.use(Router);
export default new Router({
    routes: [
        {
            path: '/',
            component: Index
        }
    ]
})
@wqcstrong
Copy link
Author

错误截图:error screenshots

@erguotou520
Copy link

哥,不是这么玩的,你不能直接import .vue文件

@wqcstrong
Copy link
Author

@erguotou520 那应该怎么做呢

@wqcstrong
Copy link
Author

@erguotou520 大佬可以加微信私聊一下吗

@erguotou520
Copy link

目前(应该还没有)还不支持.vue直接加载的方式,vue那边也在做相关的工作,后续应该可以有支持。目前的做法是建议直接用.js文件,用render函数渲染

@wqcstrong
Copy link
Author

wqcstrong commented Dec 12, 2017

@erguotou520 ok,谢谢指点!

@erguotou520
Copy link

可以看下我这个#93 里的项目

@davidnagli
Copy link
Contributor

@erguotou520 I did my best to understand the discussion via Google Translate, and from what I understand this is a duplicate of #5 and #199.

Can we close this?

@erguotou520
Copy link

Yes, should be closed.

@wqcstrong
Copy link
Author

@davidnagli OK, do it.

@trustgig
Copy link

Thank you.

@BoltDoggy
Copy link

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

No branches or pull requests

6 participants