- Full-Stack Vue.js 2 and Laravel 5
- Anthony Gore
- 125字
- 2021-07-02 19:57:23
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.
推薦閱讀
- Delphi程序設(shè)計基礎(chǔ):教程、實驗、習(xí)題
- 實戰(zhàn)Java程序設(shè)計
- Servlet/JSP深入詳解
- HTML5入門經(jīng)典
- C++寶典
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- Android傳感器開發(fā)與智能設(shè)備案例實戰(zhàn)
- 區(qū)塊鏈項目開發(fā)指南
- ActionScript 3.0從入門到精通(視頻實戰(zhàn)版)
- Struts 2.x權(quán)威指南
- 30天學(xué)通C#項目案例開發(fā)
- 深度實踐KVM:核心技術(shù)、管理運維、性能優(yōu)化與項目實施
- Photoshop智能手機(jī)APP界面設(shè)計
- Web前端開發(fā)最佳實踐
- Java EE項目應(yīng)用開發(fā)