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

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.

主站蜘蛛池模板: 福安市| 湟中县| 长葛市| 鄯善县| 蒲江县| 太原市| 醴陵市| 深水埗区| 安宁市| 章丘市| 淳化县| 连江县| 合山市| 巢湖市| 三穗县| 武功县| 东城区| 黄梅县| 湄潭县| 延庆县| 涞源县| 平顶山市| 遵义市| 西藏| 翼城县| 遵化市| 江城| 四子王旗| 三台县| 姚安县| 东莞市| 桂平市| 汝南县| 巴彦淖尔市| 新绛县| 庄浪县| 丹棱县| 淮滨县| 吴江市| 环江| 平塘县|