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

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.

主站蜘蛛池模板: 凉山| 赤壁市| 晋宁县| 油尖旺区| 呼图壁县| 东兴市| 大同县| 清水县| 宜昌市| 邯郸县| 陆丰市| 呼伦贝尔市| 多伦县| 克山县| 二手房| 远安县| 沧州市| 靖安县| 铜陵市| 元阳县| 福泉市| 长治市| 鞍山市| 碌曲县| 丰镇市| 金昌市| 齐齐哈尔市| 海安县| 泸溪县| 阳春市| 讷河市| 灵丘县| 霸州市| 九寨沟县| 南溪县| 益阳市| 朝阳区| 汉寿县| 扎鲁特旗| 安庆市| 江津市|