Home > Web Front-end > JS Tutorial > body text

What does el mean in vue

(*-*)浩
Release: 2019-05-25 10:03:04
Original
16066 people have browsed it

el

What does el mean in vue

## Type: String | HTMLElement | Function

Restrictions: Can only be functions in component definitions.

Details:

Provides mounting elements for instances. The value can be a CSS selector, an actual HTML element, or a function that returns an HTML element. Note that the element is only used as a mount point. If a template is provided the element is replaced unless replace is false. Elements can be accessed with vm.$el.

It must be a function value when used in Vue.extend, so that all instances will not share elements.

If this option is specified during initialization, the instance will immediately enter the compilation process. Otherwise, you need to call vm.$mount() to start compilation manually.

The provided element can only be used as a mount point. Different from Vue 1.x, all mounting elements will be replaced by the DOM generated by Vue. Therefore, it is not recommended to mount the root instance to or .

If neither the render function nor the template attribute exists, The HTML of the mounted DOM element will be extracted and used as a template. At this time, the Vue library built by Runtime Compiler must be used . Everyone knows the role of

el, which is used to specify the mounting target of the Vue instance. We focus on the above two parts. 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 as a template

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <div id="ppp"></div>
    </body>
</html>
Copy after login

Example: DOM rendered by render function replaces

new Vue({
    el: '#ppp',
    router,
    store,
    render: h => h(App)
})
Copy after login

The above is the detailed content of What does el mean in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template