Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the function of vuejs el?

Shulou Source: shulou.com Published: 2022-06-03 10:44:09 11月15日 Update

This article is to share with you what the role of vuejs el is, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.

In vuejs, the role of el is to indicate the mount target of the Vue instance and to provide a DOM element that already exists on the page as the mount target of the Vue instance; after the instance is mounted, the element can be accessed using "vm.$el".

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

In the official API document, el is described as follows:

Https://cn.vuejs.org/v2/api/#el

As we all know, el is used to indicate the mount target of Vue instances. Let's focus on the above two red exclamation marks. To sum up, 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 resides will be extracted and used as a template

Example 1: DOM replacement for render function rendering

New Vue ({el:'# ppp', router, store, render: h = > h (App)})

Example 2: string template replacement

New Vue ({el:'# ppp', router, components: {App}, template:''})

Example 3: manual mount with no render function and template property

New Vue ({router, store,}). $mount ('# ppp')

The above is what the function of vuejs el is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Function element instance function goal example that is attribute more template knowledge article part practical two exclamation mark character string official work meeting Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL macOS Redmi Microsoft