[Vuejs]-Why in vue object, this line only need half tag 'template: "<App/>" '

0👍

It’s short for

<App></App>

It only works in string templates (template: '....' or .vue files), not in in-DOM templates in your .html page.

The reason is that this short form isn’t valid HTML after the latest specification (these self-closing elements existed in earlier versions of the HTML spec, though, i.e. <img src="http://..."/>)

Since string templates are never touched by the browser’s DOM engine, we can allow this shortcut in those.

Leave a comment