mercredi 23 décembre 2020

Vue replacing "el" component instead of rendering inside it?

I don't know if this is a standard feature but Vue is replacing the element specified by "el" when the instance is created, instead of rendering inside of it.

if I use an id to reference the "el" then it works fine. ie,

new Vue({el: "div#app", render: h => h("span", {}, "Hello World")})

which will render as:

<body><div id="app"><span>Hello World</span></div></body>

but if I use a JS Element object as "el" then it replaces that element altogether.

const divElement = document.querySelector("div#app");
new Vue({el: divElement, render: h => h("span", {}, "Hello World")});

will render as:

<body><span>Hello World</span></body>

is it supposed to do that, or am I doing something wrong?




Aucun commentaire:

Enregistrer un commentaire