Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of vuejs el?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report