How to get the value of el in the Vue?

Asked

Viewed 374 times

3

I have the variable Vue:

var appExemplo = new Vue({
    el: "#appExemplo"
});

How can I take the value that’s in el? That in this example would be #appExemplo.

This.el return undefined.

1 answer

5


you want to get the DOM manipulated by vue?

you can use the property $el

var appExemplo = new Vue({
  el: "#appExemplo",
    data: {
    message: 'Hello World!'
  }
});

console.log(appExemplo.$el.id, appExemplo.$el);
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script>
<div id="appExemplo">
  {{ message }}
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.