- 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.
推薦閱讀
- 數據科學實戰手冊(R+Python)
- Advanced Machine Learning with Python
- Java范例大全
- Progressive Web Apps with React
- 軟件項目管理(第2版)
- React Native Cookbook
- INSTANT Django 1.5 Application Development Starter
- Jupyter數據科學實戰
- 深度學習:Java語言實現
- ElasticSearch Cookbook(Second Edition)
- ASP.NET程序開發范例寶典
- Java Fundamentals
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- Django 3.0應用開發詳解
- 創意UI:Photoshop玩轉APP設計