Talking about how to bind variable values of vue to prevent changes, and talking about vue

Source: Internet
Author: User

Talking about how to bind variable values of vue to prevent changes, and talking about vue

1. Object. freeze (obj) Statement

Obj = {foo: "nan"} Object. freeze (obj );

After the variable is fixed with this statement, changes to this variable will be invalid and an error will be reported in the console.

2. Bind the v-once Element

<Span >{{ msg }}</span>

After the msg data changes, the span content also changes immediately.

<Span v-once >{{ msg }}</span>

If the v-once binding is added, even if the msg in the data changes the content in the span, it will not change. However, this does not prevent data changes, but is only bound with an html element so that it cannot be changed.

The above discussion about the value of several vue binding variables to prevent the change is to share all the content with you in small series. I hope to give you a reference, and I hope you can also support the help house.

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.