- 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
- 大學(xué)計(jì)算機(jī)基礎(chǔ)(第三版)
- Mastering AWS Lambda
- PyTorch自然語(yǔ)言處理入門與實(shí)戰(zhàn)
- 機(jī)器人Python青少年編程開發(fā)實(shí)例
- Python程序設(shè)計(jì)
- FLL+WRO樂高機(jī)器人競(jìng)賽教程:機(jī)械、巡線與PID
- Haxe Game Development Essentials
- Hands-On Full Stack Development with Go
- RESTful Java Web Services(Second Edition)
- JavaScript機(jī)器人編程指南
- Mastering Android Studio 3
- PHP典型模塊與項(xiàng)目實(shí)戰(zhàn)大全
- 生成藝術(shù):Processing視覺創(chuàng)意入門
- Scratch 3.0少兒積木式編程(6~10歲)