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

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.

主站蜘蛛池模板: 观塘区| 巴彦淖尔市| 梁山县| 元朗区| 光山县| 郧西县| 从化市| 五台县| 喜德县| 揭西县| 光泽县| 吉安县| 克山县| 灯塔市| 岚皋县| 奉贤区| 分宜县| 定结县| 台安县| 上林县| 和硕县| 湖口县| 东兴市| 九寨沟县| 南宫市| 清苑县| 芜湖县| 筠连县| 兰州市| 榆社县| 密山市| 苗栗市| 虎林市| 南皮县| 察雅县| 特克斯县| 多伦县| 安吉县| 建湖县| 资溪县| 阜南县|