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

<div id="app"> is in App.vue and index.html #4158

Closed
GreggOD opened this issue Jun 17, 2019 · 1 comment
Closed

<div id="app"> is in App.vue and index.html #4158

GreggOD opened this issue Jun 17, 2019 · 1 comment

Comments

@GreggOD
Copy link

GreggOD commented Jun 17, 2019

Version

3.8.0

Reproduction link

https://codesandbox.io/s/vue-template-p5kdn?fontsize=14

Steps to reproduce

Install @vue/cli;
Create a project;
In main.js change mount to:

new Vue({
  el: "#app", // because this id exists twice
  components: { App },
  template: "<App/>"
});

watch app serve fail because #app exists in App.vue and index.html.

What is expected?

App to mount

What is actually happening?

App is failing to mount due to duplicate id


While helping someone implement ant-design package with vue cli I noticed in App.vue its root element is a div with the id of "app".
Then in public/index.html there is also a div with id "app".

The id should be removed from App.vue

@Akryum
Copy link
Member

Akryum commented Jun 17, 2019

When Vue mount the app, the entire outer HTML of the target element is replaced with the rendered templates & components. Which means in the end there is only one <div id="app">. But this doesn't even matter because mounting isn't done yet when Vue looks for the el target. So whatever you put in the template isn't rendered to the DOM at this stage.

watch app serve fail because #app exists in App.vue and index.html.

So this is impossible.

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