A VUE component (and the app itself) have an el: and also a template.
I want to understand what the difference is, when do I use one and when the other:
If I create a project with Monaca CLI from the minimal VUE-OnsenUI template I see:
new Vue({
el: '#app',
template: '<app></app>',
components: { App }
});
From the very verbose documentation lacking examples, to make a long story short, I gather that the template dom element and everything in it will replace the el dom element. (The template can only have a single root, right?). For example : If my html is:
<html>...
<body>...
<replaceThis></replaceThis>...
and my vue js says:
el: "replace-this",
template: "<div id='replaced'>hi there</div>"
Then I will get :
<html>...<body>...<div id='replaced'>hi there</div>...
but I can also write:
el: "#bla",
template: "#blu"
Then if my html is
<html>
<body>
<div id="bla">
anything inside here including the surrounding div will be replaced
</div>
<template id="blu">
<span id ="replacing-html">
when ran in span, it stays mainly in the pan
</span>
</template>
</body>
</html>
then the div with id bla will be replaced with the replacing-html span elelment that is inside the template. (the template tag itself with everything in it will still remain in the emitted html. correct?)
So I need to understand:
- Is the
templatecontent replacing theelelement? - Must the
templateonly have a single root element directly under it? - Am I correct with my first example?
- Am I correct about the second example?
- Will the
templatetag with everything in it remain in the emitted html? - What happens in the case of the Monaca Vue-OnsenUI example above where the
elis the same as the template: "app". Isn't this recursive? What is replaced and with what?