Skip to content

Can't get router to work with components in Runtime mode #824

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

Closed
heroic opened this issue Oct 23, 2016 · 5 comments
Closed

Can't get router to work with components in Runtime mode #824

heroic opened this issue Oct 23, 2016 · 5 comments

Comments

@heroic
Copy link

heroic commented Oct 23, 2016

I created a default webpack project with vue-cli, and changed the main.js file to match the example here: https://github.com/vuejs/vue-router/blob/next/examples/basic/app.js

With one difference though. I removed the "template" part in the code. I now expect it to render the component in the "el", since the template is already parsed into the main bundle js.

@fnlctrl
Copy link
Member

fnlctrl commented Oct 24, 2016

Hi, thanks for filling this issue.

I removed the "template" part in the code. I now expect it to render the component in the "el"

You need standalone build for this.

since the template is already parsed into the main bundle js.

No it's not. Runtime only build can only handle render functions, anything other than that (template string, in-dom templates) are not supported.

@fnlctrl fnlctrl closed this as completed Oct 24, 2016
@heroic
Copy link
Author

heroic commented Oct 24, 2016

@fnlctrl If I am looking at the generated js file, I am seeing the render function, as created by Webpack. Isn't this the render function you are mentioning?

@fnlctrl
Copy link
Member

fnlctrl commented Oct 24, 2016

Yes. Then there may be some other things wrong here.. Need a reproduction repo to look into.

@fnlctrl fnlctrl reopened this Oct 24, 2016
@posva
Copy link
Member

posva commented Oct 24, 2016

If the template is on the index.html I doubt I'ts parsed by vue-loader.

You should bundle that template into an App.vue component then use it in main.js like this:

import App from './App.vue'

new Vue({
  router,
  el: '#app', // equivalent to mount
  render: h => h(App)
})

@fnlctrl
Copy link
Member

fnlctrl commented Oct 28, 2016

Closing due to inactivity.

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

3 participants