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

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.

主站蜘蛛池模板: 新密市| 陈巴尔虎旗| 新巴尔虎左旗| 夏邑县| 农安县| 金沙县| 芜湖市| 临汾市| 揭东县| 崇明县| 临高县| 丹巴县| 古浪县| 泗洪县| 饶平县| 沐川县| 马龙县| 正安县| 姚安县| 广南县| 林芝县| 遵义市| 清水河县| 正阳县| 田阳县| 确山县| 兴宁市| 晋江市| 平阳县| 辛集市| 柏乡县| 沾益县| 六安市| 松原市| 新竹市| 麻城市| 凉山| 淮阳县| 会东县| 赣州市| 拉萨市|