- 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.
推薦閱讀
- ExtGWT Rich Internet Application Cookbook
- Kibana Essentials
- Oracle 11g從入門到精通(第2版) (軟件開發視頻大講堂)
- Android開發精要
- 算法精粹:經典計算機科學問題的Java實現
- Django開發從入門到實踐
- Software Testing using Visual Studio 2012
- Practical DevOps
- Vue.js 3.0源碼解析(微課視頻版)
- Web Application Development with MEAN
- WebRTC技術詳解:從0到1構建多人視頻會議系統
- C++面向對象程序設計習題解答與上機指導(第三版)
- C語言程序設計
- JavaScript應用開發實踐指南
- Getting Started with Python