Vue self-study exercises, use case demo of calculated properties

Vue self-study exercises, the use case demo of calculated attributes! Vue is really considerate and solves many difficulties in data rendering. For example, front-end pages often have embarrassing situations where the results cannot be rendered in time after some data changes. With vue, you are not afraid.

You can use the computed attribute to define the area you want to control. Once the attribute value in this area changes, you can immediately see a series of corrected data results, which are rendered on the front-end page.

The following is a simple case show.

This is an original string at the front end, if the customer modifies the content of this string, then,

Followed by the matching calculated property: reverseMessage, the corrected value will be displayed immediately.

It relies on the calculated properties in the vue object. computed

As shown in the figure, this calculated attribute is in a level relationship with data and methods.

This way of writing saves the need for monitoring operations, and Vue will help you monitor data changes in real time. Respond automatically.

In the front-end page, modify the value of message2 with the help of the console command, and you can see that it will also change immediately, and the corresponding reverseMessage

Is it convenient? If you like front-end development, be sure to learn Vue.

Guess you like

Origin blog.csdn.net/yrldjsbk/article/details/129184152