官术网_书友最值得收藏!

Vue's mount element

What if we just mounted Vue on thebodytag, wouldn't that solve our problems? For example:

new Vue({
  el: 'body' 
});

This is not permitted by Vue and if you attempt it you will get this error: Do not mount Vue to <html> or <body> - mount to normal elements instead.

Remember that Vue has to compile the template and replaces the mount node. If you have script tags as children of the mount node, as you often do withbody, or if your user has browser plugins that modify the document (many do) then all sorts of hell might break loose on the page when it replaces that node.

If you define your own root element with a unique ID, there should be no such conflict.

主站蜘蛛池模板: 凤山县| 镇雄县| 静乐县| 彭山县| 洪湖市| 水城县| 娄底市| 防城港市| 名山县| 随州市| 清水河县| 麻阳| 天峻县| 淄博市| 东城区| 荆门市| 乌海市| 南丹县| 内丘县| 乌什县| 铜陵市| 郴州市| 两当县| 顺平县| 宕昌县| 盐山县| 左云县| 白城市| 睢宁县| 寻乌县| 平武县| 余庆县| 江城| 南宫市| 开阳县| 甘洛县| 溆浦县| 淅川县| 东源县| 玉山县| 莱州市|