What are Vue instance properties?
When defining a new Vue instance, the constructor function accepts an object as a parameter through which all Vue instance options are defined. Within that object, Vue.js already provides predefined properties each with its own characteristics, which enable the operation of the Vue application. The following list represents the basic properties of each Vue instance and are accessed outside the instance with the $ sign.
Next to them, three very important properties are mentioned: computed, methods and watch which act as proxies (read more about this in the article “Accessing Vue instance properties”).
“$el”
As of version 3.0 $el can be used to access the underlying DOM element, mostly with components that use fragments. However, it is recommended that starting with version 3.0, the reliance on $el should be avoided, but instead the template references $refs should be used as direct access to DOM elements.
Within the 2.0 version with the property “el” we define the HTML element that will be “managed” by the Vue application:
HTML
|
1 |
<div id="some Selector"></div> |
JavaScript
|
1 2 3 |
new Vue ({ el: "#nekiSelektor" }) |
