What exactly is vue instance property vm.$els? What should I pay attention to? Please read this article for details.
No expression required
parameter:id (required)
usage:
Register an index for the DOM element to facilitate accessing this element through $els of the instance.
Notice:
Because HTML is case-insensitive, camelCase name such as v-el:someEl will be converted to all lowercase. This.$ can be set with v-el:some-el.
My understanding:$els is similar to ('.class') function, and you can get the specified dom element.
Eg:
<div v-el:mainContainer></div>
var _dom = this.$
Note: When taking the dom element, the camel name is not recognized. As in the example above, the bound value is mainContainer, but when taking the dom, you can only write the maincontainer, otherwise it will not be recognized.
In fact, in the previous article, I used the instance attribute of vue vm.$els
HTML code:
<input type="text" class='name-input' placeholder='Please fill in the project name' v-on:='saveProjectFun' v-el:addProject>
js code:
// When the user presses Enter, save the added items saveProjectFun:function(){ var obj={} =false; let name=this.$; =(/\s+/g,""); (obj); =true; }
actually this.$It is equivalent to:('.name-input').value
This article has been compiled intoFront-end component learning tutorial》, everyone is welcome to learn and read.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.