Vue Instance property vm. What the hell is $els? What do you need to be aware of? Please read this article specifically.
Do not need an expression
parameters: ID (required)
Usage:
Registers an index for DOM elements to facilitate access to this element through the $els of the owning instance.
Attention:
Because HTML is case-insensitive, camelcase names like V-el:someel will be converted to all lowercase. You can use V-el:some-el to set this. $els. Someel.
My understanding:$els Similar to the Document.queryselector ('. class ') feature, you can get the specified DOM element.
Eg:
<div v-el:maincontainer></div>
var _dom = this. $els. Maincontainer
Note: When fetching the DOM element, the hump name is not recognized, as in the example above, the bound value is Maincontainer, but the DOM can only be written maincontainer, otherwise it will not be recognized.
In fact, in the last article I used the Vue instance attribute vm. $els
HTML code:
<input type= "text" class= ' name-input ' placeholder= ' please fill in the project name ' v-on:keyup.enter= ' Saveprojectfun ' V-el:addproject >
JS Code:
When the user presses ENTER, save the added item
saveprojectfun:function () {
var obj={}
Obj.success=false;
Let Name=this. $els. Addproject.value;
Obj.projectname=name.replace (/\s+/g, "");
This.projectData.push (obj);
this.addp=true;
}
Actually this . $els. Addproject.value is equivalent to:document.queryselector ('. Name-input '). Value
This article has been organized into the "Vue.js front-end component Learning course", welcome to learn to read.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.