In vuejs, the function of el is to specify the mounting target of the Vue instance, and will provide a DOM element that already exists on the page as the mounting target of the Vue instance; after the instance is mounted, the element can Use "vm.$el" to access.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
In the vue official API document, el has the following description:
https://cn.vuejs.org/v2/api/#el
# Everyone knows the role of
##el, which is used to specify the mounting target of the Vue instance. We focus on the two red exclamation mark parts above. To summarize:If there is a render function or template attribute, the mounted element will be replaced by the DOM generated by Vue; otherwise, the HTML where the mounted element is located will be extracted and used Make a template
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <div id="ppp"></div> </body> </html>
new Vue({ el: '#ppp', router, store, render: h => h(App) })
new Vue({ el: '#ppp', router, components: { App }, template: '<App/>' })
new Vue({ router, store, }).$mount('#ppp')
vue.js Tutorial"
The above is the detailed content of What is the use of vuejs el?. For more information, please follow other related articles on the PHP Chinese website!