Home >
front end > The difference between string template and DOM template
The difference between string template and DOM template
Recently saw vue official document, repeatedly mentioned string template and dom template, comparison on the concept of fuzzy, check postscript LuGong reference in the future,
1. The string template
String template is written in the vue template defined in the template, such as. Vue of single component template file and define the component template attribute value templates, template string not initialized to participate in the rendering of the page in the page will be vue parsing the compiled by browsers render again, so is not limited to the HTML structure and name tag,
Vue.com ponent (' MyComponentA '{
The template: '& lt; Div MyId="123" & gt; Hello, world
'
})
2. Dom template (or called Html template) Dom template is written in HTML file, open the browser will be parsed rendering, so we must follow the naming of HTML structure and labels, otherwise the browser does not parse also cannot access to content,
The following example will not be correctly apply colours to a drawing, will be parsed into mycomponent, but registered vue components is mycomponent, unable to render,
<meta charset="utf-8" & gt;
Vue Component <body>
Hello Vue