Vue Instance Properties (VM. $els)

Source: Internet
Author: User

    • Do not need an expression

    • Parameters: id Required

    • Usage:

      Registers an index for the DOM element, facilitating access to the element through the owning instance $els .

    • Attention:

      Because HTML is case-insensitive, CamelCase names v-el:someEl will be converted to all lowercase. Can be v-el:some-el set with this.$els.someEl .

My understanding : $els Similar to the Document.queryselector ('. class ') function, 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 naming is not recognized, as in the example above, the value of the binding is Maincontainer, but only Maincontainer is written when fetching the DOM, otherwise it will not be recognized.

In fact, in the last article I used the Instance property VM of Vue. $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:

 //   Saveprojectfun:function () { var  obj={}      obj.success  =false  ;      Let name  =this   =name.replace (/\s+/g,        );       this  .projectdata.push (obj);  true  ; }

In fact this $els. Addproject.value is equivalent to: Document.queryselector ('. Name-input'). value

Vue Instance Properties (VM. $els)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.